I am trying to print 20 spaces away from the left margin
But it is not working....anything wrong with my code
cout.setf(ios::left, ios::adjustfield);
cout <<"\n\n\n"<<setw(20)<<addr1;
I am trying to print 20 spaces away from the left margin
But it is not working....anything wrong with my code
cout.setf(ios::left, ios::adjustfield);
cout <<"\n\n\n"<<setw(20)<<addr1;
Well, assuming you are using std::strings, try:
This will add 20 spaced before the start of whatever you are trying to output.Code:cout.setf(ios::right, ios::adjustfield); cout << "\n\n\n" << setw(20+addr1.length()) << addr1;
Claus Hetzer
Compiler: Borland 5.5 (on Windows)
Solaris CC (on Unix)
Known Languages: C++, MATLAB, Perl, Java
I mean using string variables instead of char*, like
strings have the length() method, which is how I would implement what you are trying to do.Code:string thisString; // this is good char[30] thatString; // this is not
Claus Hetzer
Compiler: Borland 5.5 (on Windows)
Solaris CC (on Unix)
Known Languages: C++, MATLAB, Perl, Java