memcpy is not supposed to check for any terminating null character in the source, so why does it stop at the terminating zero character?
I want to copy a binary file.
char buf = "bbbbbbbbb";
memcpy (buf, "$\0aaa", 5);
cout << buf << endl;
It doesn't. But using << to print a char pointer does.
Haha, awesome! Thanks! :)
Indeed, had it not copied the \0, then you'd get "$bbbbbbbb"
You've probably already got it by now, but just fyi, you could do this instead, to output the whole thing, nulls and all:
for (int i=0; i<sizeof(buf), ++i)
cout << buf[i];
Do you have a good reason for not using std::copy?
@iMalc good idea, Ill know it next time.
Didnt know std::copy was working with C-style strings. Thanks.
Everything with an iterator interface (that include pointers) are supported, by design.
Originally Posted by Ducky