Enter a string of English text, statistics pointer method wherein letters (case insensitive) number.

Enter a string of English text, statistics pointer method wherein letters (case insensitive) number.

#include<iostream>
#include<string>
using namespace std;
int main()
{
	char str[50];
	int n=0;
	char *p;
	p=str;
	cout<<"请输入字符串:"<<endl;
	cin>>str;
	for(int i=0;*p!='\0';p++)
	{
		if(('a'<=*p && *p<='z') || ('A'<=*p && *p<='Z'))
		{
			n++;
			cout<<*p<<" ";
		}
		else
			break;
	}
	cout<<"字符串的数量为:"<<n<<endl;
	return 0;
}

Summary:
for circulation inside the three statements can not have any relationship, but each statement has the role of each statement.

Guess you like

Origin blog.csdn.net/weixin_43803070/article/details/92798271