Suppose I have a string s which is given below:
string s="i am\ngoing\nto\ncuet";
I want to align the string to the right during display in console. So I want to show output like this:
EDIT: rightmost characters should be aligned.
i am
going
to
cuet
I tried this code to show the output:
cout.width(75);
cout<<s;
But it only right align the first line like this:
i am
going
to
cuet
Then I tried this code to get the output:
for(int i=0 ; i<s.size(); i++)
{
cout.width(75);
cout<<s[i];
}
But I get peculiar output using this code:
i
a
m
g
o
i
n
g
t
o
c
u
e
t
How can I get the desired output?