i write a code that coun t the number of upper case letter in a string there is a problem
my code count space as capital letter
code is below
#include<iostream>
#include<conio.h>
#include<cstring>
#include<string.h>
using namespace std;
class Letters{
private:
char str[20];
int num;
public:
Letters(){
str[0]='\0';
num=0;
}
void inputString(){
cout<<"Enter any String = ";
cin.getline(str,20);
}
void capitalLetters(){
int i=0;
char ch;
while(str[i]!='\0'){
if(str[i]==toupper(str[i]))
num++;
i++;
}
}
void show(){
cout<<"\nString Is = "<<str<<endl;
cout<<"Number Of Capital Letters = "<<num<<endl;
}
};
int main()
{
Letters ob;
ob.inputString();
ob.capitalLetters();
ob.show();
getch();
return 0;
}
and wrong output of my program is below
Enter any String = hello world
String Is = hello world
Number Of Capital Letters = 1
how can i solve it