<分区>
《C 编程 - 绝对初学者指南》第 19 章,示例 2,带有 strcat() 函数的程序:
#include <stdio.h>
#include <string.h>
int main()
{
char city[15];
char st[3];
char fullLocation[18];
puts("What town do you live in? ");
gets(city);
puts("What state do you live in? (2-letter abbreviation)");
gets(st);
strcat (fullLocation, city);
strcat (fullLocation, ", ");
strcat (fullLocation, st);
puts("\nYou live in ");
puts(fullLocation);
return 0;
}
当我编译这个程序时,它会显示:
编译器在控制台窗口中的输出:
有什么想法或解释为什么会显示这些奇怪的字符吗?