无字符串结束符,字符串拷贝越界:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void) {
char str1[10], str2[10];
for(int i=0; i<10; i++)
str1[i] = 'a';
strcpy(str2, str1);
printf("%s\n", str2);
system("pause");
return 0;
}
无字符串结束符,字符串拷贝越界:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void) {
char str1[10], str2[10];
for(int i=0; i<10; i++)
str1[i] = 'a';
strcpy(str2, str1);
printf("%s\n", str2);
system("pause");
return 0;
}