Setw() function not working..!!

I tried using the setwidth command but to no avail.
1.)Code- https://drive.google.com/file/d/0ByQH6SasL4r4RVVpR3BwdVNIbTA/view?usp=sharing
2.)Output- https://drive.google.com/file/d/0ByQH6SasL4r4M2FUTHBKNjgzVjA/view?usp=sharing

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
main()
{

 cout<<setw(10)<<"**********BANK MANAGEMENT**********"<<endl;
 cout<<setw(10)<<"1. Create a New Account."<<endl;
 cout<<setw(10)<<"2.View Your Account."<<endl;
 cout<<setw(10)<<"3.Delete Your Account."<<endl;
 cout<<setw(10)<<"4.View Transactions."<<endl;
 cout<<setw(10)<<"5.Exit."<<endl;
 cout<<setw(10)<<"Please enter a no. between 1 and 5 ";
 getch();
}
That's working just fine. Note the exit is padded to the left by spaces up to a width of 10. Try std::right if you want to right justified.
But why is only exit being shifted to the right...Not every other item.? And I am using borland c++ and don't know how to use std::right command the usual syntax doesn't work in it.!
Perhaps this is what you are looking for:
1
2
3
4
5
6
7
cout << setw(10) << ' '  << "**********BANK MANAGEMENT**********" << endl;
cout << setw(10) << ' '  << "1. Create a New Account." << endl;
cout << setw(10) << ' '  << "2.View Your Account." << endl;
cout << setw(10) << ' '  << "3.Delete Your Account." << endl;
cout << setw(10) << ' '  << "4.View Transactions." << endl;
cout << setw(10) << ' '  << "5.Exit." << endl;
cout << setw(10) << ' '  << "Please enter a no. between 1 and 5 ";

Doesn't Borland C++ have the standard headers <iostream> and <iomanip>?
Last edited on
closed account (E0p9LyTq)
JLBorges wrote:
Doesn't Borland C++ have the standard headers <iostream> and <iomanip>?


Borland C++ was last updated around 2000 (v5.5). Were the current standard headers (<iostream> vs. <iostream.h>) even a part of the ISO standard then?
<iostream> and <iomanip> were there in C++98 (ISO/IEC 14882:1998)
Topic archived. No new replies allowed.