更新时间:2022-06-23 22:21:40
strcat
连接字符串。在你的代码中,它将一个可能有效的字符串(inputstring
)连接到垃圾(copystring
未初始化)。
如果您只需要输入字符串的副本,请使用strncpy
而不是strcat
。
请注意:永远不要使用获取
。改为使用fgets
与stdin
。
strcat
concatenates strings. In your code it concatenates a possibly valid string (inputstring
) to garbage (copystring
is not initialized).
If you just need a copy of the input string, usestrncpy
instead ofstrcat
.
Please note: never ever usegets
. Usefgets
withstdin
instead.