#include <iostream>
#include <string>
#include <cctype>
usingnamespace std;
int main()
{
string word , word2;
int n;
cout<<"Please enter a string :";
getline(cin,word);
int size=word.length();
for (n=0;n<size;n++)
{
if (islower (word.at(n)))
word2.append(1,toupper(word.at(n)));
elseif (isupper (word.at(n)))
word2.append(1,tolower(word.at(n)));
}
cout<<word2;
cout<<endl;
system ("pause");
return 0;
}
This is a program use to determine string entered is upper or lower case , and convert them to lower and upper case respectively . The problem is I successfully convert the string but the cout part doesn't cout the spaces entered .
For example :
If I enter my name: "Tak Zee" into the program , it will appear as "tAKzEE" while the space is missing , please help .