Columns and rows problems,please fix this issue :)

Hi guys I did like this but I want Name , address contact number in the columns and under that I need fill the answers.

can someone please suggest me, Thanks :)

1
2
3
4
5
6
7
8
9
10
11
12
13
 
	char name[5] = "xxxx";
	char address[5] = "xxxx";
	char contactnumber[5] = "1234";
	char emailaddress[5] = "a@com";
	cout << "------------------------------------------------" << endl;
	cout << "- Name          : " << name <<         "                     -" <<endl;
	cout << "- Address       : " << address <<      "  -"<< endl;
	cout << "- Contactnumber : " << contactnumber <<"                   -"<< endl;
	cout << "- Emailaddress  : " << emailaddress << "      -"<<endl;
	cout << "------------------------------------------------" << endl;
	cin.get();
	return 0;
Last edited on
yeah but I want a table showing like lets say
name age place profession

xxxx 23 us art





I want to make something like that, so what kind of changes can i do for that code please, I ve been searching for arrays or other things.

Thanks for the quick response :).!!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

int main()
{
	string name = "John";
	int age = 24;
	string place = "city";
	string profession = "programmer";	

	cout << setw(14) << "name";
	cout << setw(8) << "age";
	cout << setw(11) << "place";
	cout << setw(13) << "profession";
	cout << endl;
	cout << "------------------------------------------------" << endl;
	cout << setw(14) << name;
	cout << setw(8) << age;
	cout << setw(11) << place;
	cout << setw(13) << profession;
	cout << endl;
}
YOu can study the code to see how fixed width for your columns. std:;setw() manupulator sets minimum width for next output. http://coliru.stacked-crooked.com/a/28f1b4d9dc126471
Woo Thank you Kevin and Miinipaa :).. Your help is highly appreciated :)...!! Im still new and learning ... This is great ..!!
Topic archived. No new replies allowed.