strcpy と strncpy の違い/欠点を理解しようとしています。誰か助けてください:
void main()
{
char src[] = "this is a long string";
char dest[5];
strcpy(dest,src) ;
printf("%s \n", dest);
printf("%s \n", src);
}
出力は次のとおりです。
this is a long string
a long string
質問: ソース文字列がどのように変更されたのかわかりません。説明によると、strcpy は '\0' に遭遇するまでコピーし続ける必要があります。
説明してください。