a="DATA";
. "DATA" . , , ,
a=(char *)calloc(1,(sizeof(char)));
char.
memcpy(s,a,(strlen(a)));
, ( "DATA" ) , s. , s char, 1 char - .
strlen(a) 4 ( "DATA" ) memcpy 4 char. , , C , "null" char ('\ 0') . "DATA" "D" "A" "T" "A" "0".
, , .
To copy strings, use strcpy(or strncpy) instead , it will also copy the string with its final zero byte. ( strcpyless "safe" because you can overflow the destination buffer).
But the biggest problem that I see here is that you reserve the only char only for (and you destroy it) and s, so DATA \ 0 does not fit anywhere.
source
share