Mail Archives: djgpp/1998/12/09/08:10:40
Freddie Schwenke (freddie DOT schwenke2 AT sanlam DOT co DOT za) wrote:
: I'm using DJGPP to learn C. I also want to use this tool to train people in
: C. I came accross a problem when I tried the memcpy() and memmove()
: functions tho'.
: memmove() seems to do what it is supposed to do. I have no problem with
: that.
: memcpy() gives some weird results tho'.
: char
: buffer[11] = "abcdefghij";
: memcpy(buffer + 1, buffer, 9);
: Should this not result in buffer = "aaaaaaaaaa"???
: Well it does...IF the string contains a maximum of 15 characters (excluding
: the null character). The moment the length exceeds 15 characters I get
: weird results.
: Any suggestions or comments will be appreciated.
Well, learn to read the man page. memmove's page says that overlapping
regions will be copied correctly. There are no such statement for memcpy
although it says the function works as efficiently as possible (i. e.
indeterminate results if overlapping regions.
Right,
MartinS
- Raw text -