0

Why for "The Spy Life" this code doesn't work with ASCII code :

#include <iostream> #include <string> using namespace std; int main() { string s; cin>>s; int n; n=s.size(); for(int i=n-1;i>=0;i--){ if((s[i]<91 && s[i]>64) || (s[i]>96 && s[i]<123) || s[i]==' '){ cout<<s[i]; } } return 0; }

10th Aug 2020, 6:25 PM
Arshia44
Arshia44 - avatar
1 Respuesta
+ 1
cin>>s; by this, cin accept only single word. You need read entire line of string contains more words also.. Use getline method... getline(cin, s);
10th Aug 2020, 6:42 PM
Jayakrishna 🇮🇳