Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
尽管我的程序提供了所需的输出。有许多警告显示scanf()不应该使用并尝试使用scanf_s()。
scanf()
scanf_s()
此警告的可能原因?
所有使用 scanf 函数的程序都会发生这种情况。甚至是简单的数字相加。
使用scanf, 使用一些格式参数,如果您使用无限大小的输入,您的程序可能会崩溃。scanf_s需要提供输出缓冲区的大小,从而限制缓冲区溢出的可能性(前提是您正确指定了输出缓冲区大小)。
scanf
scanf_s