S
Someonekicked
in the program im writing, i was going to output this using cout :
cout << left << setw(10) << newAccount.getNumber() << setw(18)
<< newAccount.getName() << setw(18) << newAccount.getFamName() <<
setw(11)
<< setprecision(2) << right << fixed << showpoint<<
newAccount.getBalance() << endl;
my question is, i want to declare a string , say result, and let result be
equal to the above output;
is there a way to format a string using left, setw or similar functions?
i know the following wont work, but (thats actually what i need to do ) :
string result;
result = left << setw(10) << newAccount.getNumber() << setw(18)
<< newAccount.getName() << setw(18) << newAccount.getFamName() <<
setw(11)
<< setprecision(2) << right << fixed << showpoint<<
newAccount.getBalance() << endl;
cout << left << setw(10) << newAccount.getNumber() << setw(18)
<< newAccount.getName() << setw(18) << newAccount.getFamName() <<
setw(11)
<< setprecision(2) << right << fixed << showpoint<<
newAccount.getBalance() << endl;
my question is, i want to declare a string , say result, and let result be
equal to the above output;
is there a way to format a string using left, setw or similar functions?
i know the following wont work, but (thats actually what i need to do ) :
string result;
result = left << setw(10) << newAccount.getNumber() << setw(18)
<< newAccount.getName() << setw(18) << newAccount.getFamName() <<
setw(11)
<< setprecision(2) << right << fixed << showpoint<<
newAccount.getBalance() << endl;