gpt4 book ai didi

c - gets_s 给 gcc 错误

转载 作者:太空宇宙 更新时间:2023-11-04 05:54:55 27 4
gpt4 key购买 nike

gets_s() 函数在我的编译器上不起作用。我在 GCC 中使用代码块。

这是错误:

undefined reference to '_imp_gets_s.

谁能告诉我如何解决这个错误。

最佳答案

您应该使用 fgets() 而不是 gets()gets_s()

引用 C11,§K.3.5.4.1,第 6 段,

The fgets() function allows properly-written programs to safely process input lines too long to store in the result array. In general this requires that callers of fgets() pay attention to the presence or absence of a new-line character in the result array. Consider using fgets() (along with any needed processing based on new-line characters) instead of gets_s().

关于c - gets_s 给 gcc 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29821246/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com