C语言字符串中查找字母

在字符串中(格式应该是...#...#...#...##)找大写元音字母字符(A、E、O、U、I),
然后数它的个数。

用一个for循环来遍历字符串中的内容然后比较是否为 aeiou 最后得出结果
以下是运用上面的前辈写的 哈哈
#include "stdafx.h"
#include"iostream"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
char str[]="a111a111e111i11o111u";
char *cpstr=str;
int sum=0;
while(*cpstr!='\0')
{
switch(*cpstr)
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
sum++;//累加aeiou的个数
default:{
break;}

}
cpstr++;
}
cout<<sum;
return 0;
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-01-16
int searchalp(char *)
{
int count=0;
char *string;
while(*string'\n')
{
switch(*string)
case:A:
case:E:
case:O:
case:U:
case:I:
count++;
break;
}
string++;
}
return count;
}
相似回答