Records in C++, is this right.

Delta1

In Runtime
Messages
194
Im a noob, Ive been working on a program for my college course, on my course im the guy who thinks outside the box (most likly as I am the most exprenced coder of us)

Where most people are handling records feild by field as we where tought (which is perfectly acceptable to pass the course) I've been trying to code my programs more efficent. I have been trying to handle records as records.

I'm having a little trouble with one program and heres a slimmed down version of the problem, compile it (Visual C++) and enter any 6 letters, it should display the same back but for me it messes up.

Again I am a noob so let me know if my variables are legal (creating variables from the struct as well as the table created) and if so let me know where im going wrong. I'm trying to finish the last of my 3 monday classes so I dont have to go to them for the next 8 weeks :p

Code:
#include <iostream.h>


struct studentrecord { char id[6];};

typedef studentrecord studenttable[3];

void main()
{
	studenttable students;
	studentrecord tempstudent;
	studentrecord newstudent;

	cin>>newstudent.id;

	students[0] = newstudent;
	tempstudent = students[0];

	cout<<tempstudent.id<<endl;
}
 
Back
Top Bottom