char strarr[5][10];
whe开发者_如何学JAVAn I use
strcpy(strarr[0], src);
try to copy contents from src to strarr[0] .I got seg fault.
Is this wrong?
Thanks!
Unless you show us more code we can only assume src
is more than the space availabe. Also it may be that src
is not NUL
-terminated.
It depends on what is the src
pointer, and its length.
You need to use strncpy().
strncpy(dest[0], src, 10);
精彩评论