问题描述
嗨:全部:
是一些mem cat函数,就像strcat一样?
谢谢
Hi: all:
is some mem cat function with is like "strcat" ?
Thanks
推荐答案
否。你可以realloc()一个内存区域,然后memcpy()结束另一个;
或者只是malloc()一个新的并复制两者。显然,你必须知道两个地区的大小。
S.
No. You can realloc() one memory region, then memcpy() the other at the end;
or just malloc() a new one and copy both. You must know the size of both
regions, obviously.
S.
不,而且不可能。考虑一下:strcat()如何知道
第一个字符串的结束位置?一个假设的memcat()会如何做同样的事情? (提示:
它不能。)
Richard
No, and there cannot be. Consider: how does strcat() know where the
first string ends? How would a hypothetical memcat() do the same? (Hint:
it cannot.)
Richard
不,而且不可能。考虑一下:strcat()如何知道
第一个字符串的结束位置?一个假设的memcat()会如何做同样的事情? (提示:
它不能。)
No, and there cannot be. Consider: how does strcat() know where the
first string ends? How would a hypothetical memcat() do the same? (Hint:
it cannot.)
那么,我们也不应该有memcmp吗? ;)
Then, we shouldn''t have memcmp either ? ;)
这篇关于如何实现这个功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!