small problem

when enter Life is so good then output is only lIFE......why this happen.....where is so good gone.....help
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  #include <iostream>
#include <string>
using namespace std;
string upperCase(string str){
	for(int i = 0; i <= str.size(); i++){
           if(str[i]>=97&&str[i]<=122)
    str[i]=str[i]-32;
else
    str[i]=str[i]+32;
	}
	return str;
}
int main(){
	string str ;
	cout<<"enter string = ";
	cin>>str;
	cout << "before  = " << str << endl;
	//str = upperCase(str);
	cout << "after  = " << upperCase(str) << endl;
	cin.get();
	cin.get();
	return 0;
}
Use getline instead of cin

Last edited on
i know this happen....but where are other word
Topic archived. No new replies allowed.