Y
yezi
Hi: all:
is some mem cat function with is like "strcat" ?
Thanks
is some mem cat function with is like "strcat" ?
Thanks
No. You can realloc() one memory region, then memcpy() the other at the end;yezi said:Hi: all:
is some mem cat function with is like "strcat" ?
yezi said:is some mem cat function with is like "strcat" ?
yezi said:Hi: all:
is some mem cat function with is like "strcat" ?
Richard said: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.)
Suman said:Then, we shouldn't have memcmp either ?
memcmp() doesn't have to figure out for itself where its data ends. You
tell it. You _could_ write a memcat() that you also tell yourself where
its first data block ends. It would be rather pointless, though:
void *memcat(void *dest, void *src, size_t at, size_t len)
{
Suman said:[ replying to the OP]
memcmp() doesn't have to figure out for itself where its data ends. You
tell it. You _could_ write a memcat() that you also tell yourself where
its first data block ends. It would be rather pointless, though:
Correct. To me, the strcat/memcat comparison was a poor one.
I felt free to drop a:
return
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.)
Rudolf said:Since functions like free() and realloc() know how big a memory region
is, then why can't the hypothetical memcat() know how big it is?
I haven't seen a rigorous description in this thread of just what
memcat() is supposed to do.
Rudolf said:Since functions like free() and realloc() know how big a memory region
is, then why can't the hypothetical memcat() know how big it is?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.