注意字符串第一个字符do...while

#include <iostream>
#include <string>
using namespace std;
#include <stdio.h>
#include <memory.h>
#define MAXLEN 250
int largelettersize(const char* str)
{
    int len = strlen(str);
    if(len > MAXLEN)
        return -1;
    int size = 0;
    do
    {
        if(*str >= 'A' && *str <= 'Z')
            size++;
    }while(*str++ != '\0');
 
    return size;
}
 
int main()
{
   int i = 0;
    for(i =0; i< 3;i++)
    {
        string str;
      getline(cin,str);
         cout<<largelettersize(str.c_str())<<endl;  
    }

      
          
 
}

  

posted on 2021-12-02 14:12  lydstory  阅读(13)  评论(0)    收藏  举报

导航