/*
*Copyright (c) 2014,烟台大学计算机学院
*All rights reserved.
*文件名称:Annpion.cpp
*作者:王耀鹏
*完成日期:2014年12月17日
*版本号:v1.0
*
*问题描述:用指针玩字符串。
*输入描述:不输入。
*程序输出:字符串单词数。
*/
#include <iostream>
using namespace std;
int numberchar (char *str);
int main()
{
char s[81]="I'm a vegetable bird£¡";
cout <<'\"'<<"I'm a vegetable bird£¡"<<'\"'<<"µÄµ¥´Ê¸öÊý£º"<<numberchar(s)<< endl;
return 0;
}
int numberchar (char *str)
{
int n=0;
for(int i=0; *(str+i)!='\0'; i++)
if((*(str+i)>='a'&&*(str+i)<='z')||(*(str+i)>='A')&&*(str+i)<='Z')
n++;
return n;
}
运行结果: