标题:输入一行文字,找出其中大写字母、小写字母、空格、数字及其他字符各有多少 ...
取消只看楼主
sange
Rank: 2
等 级:论坛游民
帖 子:12
专家分:26
注 册:2011-3-8
结帖率:33.33%
已结贴  问题点数:10 回复次数:1 
输入一行文字,找出其中大写字母、小写字母、空格、数字及其他字符各有多少。不知道为什么出错
输入一行文字,找出其中大写字母、小写字母、空格、数字及其他字符各有多少。请路过的高手帮我看看,谢谢
#include"stdio.h"
#include"string.h"
int main()
{
    int upper=0,lower=0,space=0,digit=0,other=0,i=0;

    char *p,s[20];
    printf("input string:");

    while(  (s[i]=getchar())!='\n')i++;
    p=s;
    while(*p!='\n')

    {
        if(  ('A'<=*p)&&(*p<='Z')  )
            ++upper;
        else if( ('a'<='*p')&&(*p<='z')  )
            ++lower;
    else if( *p=='')
        ++space;
        else if( (*p<='9')&&(*p>='0') )
            ++digit;
        else
            ++other;
        p++;
    }
    printf("upper case:%d lower case :%d",upper,lower);
    printf(" digit:%d other:%d\n",digit,other);
    return 0;

}

Compiling...
1.cpp
F:\test\88\1.cpp(20) : error C2137: empty character constant
执行 cl.exe 时出错.
搜索更多相关主题的帖子: 字母 include 
2011-04-10 13:27
sange
Rank: 2
等 级:论坛游民
帖 子:12
专家分:26
注 册:2011-3-8
得分:0 
谢谢,hjywyj
2011-04-10 13:58



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




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

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