This is a very easy question but I always struggle with it. I’m always confused about what are some good practice to take string input and output them.
suppose I have to take the input of lower case English alphabets [a - y].(not z)
string s;
cin>>s;
for(int i = 0; i < s.lenght(); i++)
cout<<s[i]+1;
Above I was trying to take the input of the string and printing the same string while incrementing the ASCII value of each character of it.
Is this the right to do it?
Or should I save this append this character into a new string and then print the result instead of using the cout again and again,
Or should I take the input in char array then calculate its length and then increment the array?
There are many ways for it and I’m unable to find out which one to choose? and which is more reliable. where to go for char array and what is the caveat with using cout multiple times?
Please clarify my google search is making this more confusing to me.