[英]why I get error: 'strcmp': identifier not found (visual studio 2010)
[英]why is it giving the error gets identifier not found in microsoft visual?
代码在代码块中运行,为什么它不在 Visual Studio 2015 中运行?
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
int main() {
char name[20];
char age[36];
char sentence[40];
puts("my name is");
gets(name);
puts("my age is");
gets(age);
strcat(sentence, "My name is ");
strcat(sentence, name);
strcat(sentence, " My age is ");
strcat(sentence, age);
puts(sentence);
_getch();
return 0;
}
从https://msdn.microsoft.com/en-us/library/bb531344.aspx :
- 获取和 _getws
get 和 _getws 函数已被删除。 get 函数已从 C11 中的 C 标准库中删除,因为它无法安全使用。 _getws 函数是一个 Microsoft 扩展,它等效于 get 但用于宽字符串。 作为这些函数的替代方法,请考虑使用 fgets、fgetws、gets_s 和 _getws_s。
并且strcat
想要一个以 NUL 结尾的字符串作为目标,更改为:
char sentence[40] = {0};
...
strcat(sentence, "My name is ");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.