gets()方法在linux下使用gcc编译时会出现下列问题:
warning: the `gets' function is dangerous and should not be used.
解决办法是使用 fgets()。
#include <stdio.h> #include <string.h> int main(){ char s[80]; //fgets()函数的基本用法为: //fgets(char * s,int size,FILE * stream); fgets(s,80,stdin);//stdin表示键盘输入 fputs(s,stdout);//stdout表示输出 return 0; }