I want to change all the characters to lowercase in a string and copy it to another string.I tried the below approach in c++ but not working as expected. It is returning the string before a whitespace.
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s,t="";
cin>>s;
for(int i=0;i<s.size();i++){
t+=tolower(s[i]);
}
cout<<t<<"\n";
return 0;
}
For example if i give the input string "HELLO WORLD", giving result only "hello". Ignoring anything after space.
Is there any way to solve this is C++?
Aucun commentaire:
Enregistrer un commentaire