My end goal is to write a program that only prints the letters in a string. through testing i found that digit will equal 0 when it is a letter (as i expected) but it wont enter the if statement. I know i have a dumb syntax error here and I'm missing it for some reason. Or maybe a larger logical error. Secondly in the the digit if the organization will take the lower case then make it an uppercase then back down to a lower again.
How can i enter the digit if when the char is a letter?
And how do i organize inside the digit if to make it possess each char as i have described?
int main(void)
{
usingnamespace std;
string str;
int size;
bool digit, upper, lower;
int counter = 0;
cout << "What is the string that you would like to have manipulated? ";
getline(cin,str, '\n');
size = str.size();
cout << size << endl;
for (int i = 0; i < size; i++)
{
//cout << "dude";
//check to see if the individual elements are digits
digit = isdigit(str[i]);
//if not dont print them
if (digit == 0)
{
//if char is lower case then make it uppercase
lower = islower(str[i]);
//cout << lower;
if (lower == 0)
{
cout << toupper(str[i]);
counter++;
}
//if uppercase then make it lower case
upper = isupper(str[i]);
else (upper = 0)
{
cout << tolower(str[i]);
counter++;
}
}
}
}
~