首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

while(gets(str)!=NULL) 和 while(gets(str)!=EOF)的区别?多谢大家帮忙

2013-04-26 
while(gets(str)!NULL) 和 while(gets(str)!EOF)的区别?谢谢大家帮忙!while(gets(str)!NULL) 和 while(

while(gets(str)!=NULL) 和 while(gets(str)!=EOF)的区别?谢谢大家帮忙!
while(gets(str)!=NULL) 和 while(gets(str)!=EOF)的区别?
什么时候用while(gets(str)!=NULL)??
什么时候用while(gets(str)!=EOF)?? C语言 编程
[解决办法]
区别就是 
gets 出错了 会返回NULL
以及 然后情况想 gets都不会返回 EOF
[解决办法]
数据类型根本不匹配 
gets 返回值类型是 char*
EOF的数据类型是 int[诸如此类 反正不是指针]
[解决办法]

引用:
引用:区别就是 
gets 出错了 会返回NULL
以及 然后情况想 gets都不会返回 EOF

谢谢,那什么时候用while(gets(str)!=NULL)??
什么时候用while(gets(str)!=EOF)??
什么时候都只能用gets != NULL
不能用 gets != EOF
因为 gets 根本不会返回EOF
gets!=EOF 恒为 1 
[解决办法]
引用:
    scanf()!=NULL ?
还是scanf()! =EOF ?
在不同情况之下都可以用吧?
谢谢!
自己查清楚 函数的具体内容
scanf怎么会返回一个NULL
什么时候都不可以写scanf != NULL
[解决办法]

gets()函数的构造如下:
char *gets(char *s)
{
   .......
   return s;
}

热点排行