By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,997 Members | 1,260 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,997 IT Pros & Developers. It's quick & easy.

i need help in using setw()

P: 4
hello everyone, i am actually new to c++.

my problem is i need to display information from a file but i don't know how to do so for more than 4 elements horizontally
. my code:

void outPutLine ( ostream &output, const empclass &record )

{
output<<left<<setw(10)<<record.getIdNumber()
<<setw(16) << record.getEmpName().data()
<<setw(11) << record.getEmpSex().data()
<<setw(10) << setprecision(2) << right << fixed
<< showpoint << record.getEmpRel().data()<< endl;
}

this works pretty well but i have 4 or 5 more functions to be in the same line
Apr 18 '07 #1
Share this Question
Share on Google+
2 Replies


weaknessforcats
Expert Mod 5K+
P: 9,197
I'm not sure I understand your question.

What's the significance of the 4 elements and what dio you mean by 4 or 5 functions on the same line?
Apr 18 '07 #2

P: 4
alright ill rephrase my question and i hope that it can be more understandable.
the thing is i am using function from a class to get the data from a file and i want to display those functions horizontally one next to the other, if i wanted to do this to some variables i would do it this way e.g cout<<"something"<<" space" <<"somethingelse" until the 8th variable but this wont work in this case:

output<<left<<setw(10)<<record.getIdNumber() ( <-- my functions)
<<setw(16) << record.getEmpName().data()
<<setw(11) << record.getEmpSex().data()
<<setw(10) << setprecision(2) << right << fixed
<< showpoint << record.getEmpRel().data()<< endl;

the reason is simply bcus i have no idea how to manipulate the setw() parameters in a way that all of my functions those retrieve the data appear in the same line.

thank you
Apr 18 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.