Can any1 help me with printing out the student record when the user inputs the information? i wrote a for loop statement to print out the user input and set the width to 60, but it doesn't print it out...

#include<iostream>
#include<iomanip>
using namespace std;
struct Record
{
	char lastName[80];
	char firstName[80];
	char id[20];
	int score;
};
int main ()
{
	Record student[5];
	char dummy;
	for(int i=0; i<5; i++){
	cout<<"Enter last name: ";
	cin>>student[i].lastName;
	dummy=getchar();
	cout<<"Enter first name: ";
	cin.getline(student[i].firstName, 80);
	cout<<"Enter id: ";
	cin>>student[i].id;
	cout<<"Enter score: ";
	cin>>student[i].score;
	}
	for(int i=0; i<5; i++){
	cout<<setw(60)<<student[i].lastName
		<<setw(60)<<student[i].firstName
		<<setw(60)<<student[i].id
		<<setw(60)<<student[i].score<<endl;
	}
}

works for me.

Wth... it didnt work when i enter the user input... didnt print it out right at all *sigh*... Visual can be such a pain in the ass :(

This is what I get on Vista. How is it different that yours ? How do you want it to display?

Enter last name: aaa
Enter first name: bbb
Enter id: 100
Enter score: 100
Enter last name: ccc
Enter first name: ddd
Enter id: 200
Enter score: 200
Enter last name: eee
Enter first name: fff
Enter id: 300
Enter score: 300
Enter last name: ggg
Enter first name: hhh
Enter id: 400
Enter score: 400
Enter last name: jjj
Enter first name: kkk
Enter id: 500
Enter score: 500
                                                         aaa
                                     bbb
                 100                                                         100

                                                         ccc
                                     ddd
                 200                                                         200

                                                         eee
                                     fff
                 300                                                         300

                                                         ggg
                                     hhh
                 400                                                         400

                                                         jjj
                                     kkk
                 500                                                         500

Press any key to continue . . .
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.