I had the program working until I wrote it with a void function. I have no idea where I've messed up. It returns 1 and gives no other errors.
#include <iostream>
#include <string>
using namespace std;
char response;
string s;
int upper, lower, other, count;
void capCheck(string);
int main()
{
count = 0;
upper = 0;
lower = 0;
do
{
cout<<"Get the number of upper and lower case letters in your sentence!!"<<endl;
cout<<endl;
cout<<"Type your sentence below without spaces.."<<endl;
cin>>s;
capCheck(s);
cout<<"Would you like to continue? Y/N"<<endl;
cin>>response;
}while(response == 'y' || response == 'Y');
return 0;
}
void capCheck()
{
while(s[count] != 0)
{
if(s[count] >= 'a' && s[count] <= 'z')
{
lower++;
count++;
}
else if (s[count] >= 'A' && s[count] <= 'Z')
{
upper++;
count++;
}
else
other++;
}
cout<<"The number of uppercase letters are: "<<upper<<endl;
cout<<"The number of lowercase letters are: "<<lower<<endl;
}
Just change void capCheck()
for void capCheck(string s)
in your function declaration. It works fine for me.
Some comments on the code: try not to use global variables and improve indenation.