读书人

:assignment makes integer from poi

发布时间: 2012-04-15 18:39:21 作者: rapoo

求救:assignment makes integer from pointer without a cast|
请问谁告诉我出现的原因是什么?怎么解决?多谢了!!!
#include <stdio.h>
main()
{
int c,nl,tab,space;
tab=0;
space=0;
nl= 0;
while ((c=getchar())!= EOF){
while (c="\n"){
nl=nl+1;}
while (c=" "){
space=space+1;}
while (c="\t"){
tab=tab+1;}
}printf("%d\n", space);
}


[解决办法]
while (c="\t"){
改为 if( c == '\t' ) {

除了第一个while之外,另外3个while都这么改。。
[解决办法]
谢谢,但是我一enter不动了

while (c==‘\n’){
nl=nl+1;
}

进入死循环。。。。当然不动了。

应该这样,记录一个“回车”输入
while (c==‘\n’){
nl=nl+1;
break;
}

读书人网 >C语言

热点推荐