character array handling in c (copy pointer to character array)
I have a pointer with type const char* FunctionName
, How can I put 开发者_开发问答that into a payload
of type char payload[100]
without any warning or errors? Also the payload[0]
is filled with character value already, so the space starting from payload[1]
update:
I tried like this `strcpy((&payload[1]),FunctionName); is working now.
But Ihave one more question, how can accomodate the pointer(FunctionName) into the payload[1]
ratherthan copying the entire string? through any assignment statement?
/R
strncpy(&payload[1], FunctionName, 98);
payload[99] = '\0';
should be safe in the case that FunctionName has more than 98 characters before the NULL terminator.
精彩评论