c89/90
c99
c11
c18
之间是否有弃用?还是只建议避免使用某些功能,例如strlen
并使用“更安全的” strnlen_s
?
答案 0 :(得分:2)
即使委员会(也非常)非常关注向后兼容性,也不能保证新的标准是兼容的。
要避免使用的功能的官方建议位于:
值得注意的是,官方建议不受有关字符串处理功能等的错误的Microsoft宣传。
您真诚的非正式建议: Which functions from the standard library must (should) be avoided?。
答案 1 :(得分:1)
由于使用了不安全的功能gets
,以下代码在C89中有效,在C99中已弃用,在C11中无效,并且进一步无效:
#include <stdio.h>
int main()
{
char str[100];
puts("What's your name?");
gets(str);
printf("Hello %s!\n", str);
}