标题:能帮我解释下两者的区别吗
只看楼主
jg658237
Rank: 7Rank: 7Rank: 7
来 自:青藏高原
等 级:黑侠
帖 子:224
专家分:529
注 册:2013-8-8
得分:2 
你这个程序有问题,无论输入多少了字母最后结果总是1.你试试吧,
程序里有重复多余的语句,我已经帮你修改好了
#include<stdio.h>
#include<string.h>
int main()
{
    char string[81];
    int i,word = 0, num = 0;
    char c;

    gets(string);

    for(i = 0;(c = string[i])!='\0';i++)    // 和 for(i=0;(c = string[i] != '\0');i++) 的区别?顺便解释下后者的意义
        
       { if(c!=' ')
          word = 0;
           num++;
        }
        
    printf("There is %d words in this line.\n", num);

        return 0;
     }
                            其中i是自负数组的下标,你仔细理解一下

武功再高也怕菜刀.
2013-09-02 10:13



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-419938-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021645 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved