char str[] = "abcdefg";
sizeof(str)的值是8而不是7!
请注意。
char str1[] = "abcdefg";
char str2[] = "hijk";
分配内存后将两串相加后注入给新分配的内存:
char* str3 = (char*)memalloc(sizeof(str1)+sizeof(str2)-1);
strcpy(str3,str1);
strcat(str3,str2);
sizeof(str)的值是8而不是7!
请注意。
char str1[] = "abcdefg";
char str2[] = "hijk";
分配内存后将两串相加后注入给新分配的内存:
char* str3 = (char*)memalloc(sizeof(str1)+sizeof(str2)-1);
strcpy(str3,str1);
strcat(str3,str2);
回复Comments
{commenttime}{commentauthor}
{CommentUrl}
{commentcontent}