我试图理解strcpy()函数,但我不能。如this page中所述,如果目标字符串长度小于源字符串,则不会将整个源字符串值复制到目标字符串中,而是将其截断。但是当我试图运行这个程序时
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char my_full_name[]="TomCruse_MI";
char my_school_name[]="DON_BOSCO";
strcpy(my_school_name, my_full_name);
printf("After strcpy() function to copy my name into my school : \'%s\'\n" , my_school_name);
printf("\n");
return 0;
}
我正在接受:
After strcpy() function to copy my name into my school : 'TomCruse_MI'
我的问题是,即使源字符串大于目标大小,字符串'TomCruse_MI'也不会被截断。