I have an output file name out
using the below code to add a string to the text file:
string foo = "Hello, foo";
out << foo;
How can I customize a string to input into out file
adding string and numbers with a specific width using setw(7)
Your name is:AName you are 18
Your name is:foo you are 30
with variable name
holding the name and variable age
holding the age
how can I make this code works
out<< ("Your name is :"+ setw(7)+ name +" you are " + age);
It is just as simple as
setw
does not return a string that you can concatenate. It returns an unspecified type that can be passed tooperator <<
of an output stream.