[Dev-C++] Problem with Struct loop...
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: RakSmei P. <rak...@ya...> - 2013-01-14 17:17:44
|
Dear all…
Please help fix the following source code I got error while try to input all values from Keyboard to store in array of struct... I mean to make an
example of recording all data Tables in Database...
Thanks in advance....!
Regards....!
#include<iostream>
#include<conio.h>
#include<string.h>
using namespace std;
struct Score{
double Point;
char Subj[10];
};
struct Student{
double ID;
char FirstName[20];
char LastName[20];
char Sex;
};
main(){
int Nstu,Nsubj,i,j;
cout<<"Enter Amount
of Student";
cin>>Nstu;
cout<<"Enter Amoun of
Subject";
cin>>Nsubj;
Score Data[Nsubj*Nstu];
Student Info[Nstu];
for (i=0;i<Nstu;i++){
cout<<"Input ID:
";
cin>>Info[i].ID;
cout<<"Input Name:
";
cin>>Info[i].FirstName;
cout<<"Input
LastName: ";
cin>>Info[i].LastName;
cout<<"Input Sex:
";
cin>>Info[i].Sex ;
for(j=0;j<Nsubj;j++){
cout<<"Input
Subject: ";
cin>>Data[j].Sub;
cout<<"Input
Scores: ";
cin>>Data[j].Point;
};
};
for (int o=0;o <Nstu;o++){
cout<<Info[o].ID
<<" "
<<Info[o].FirstName <<" " <<Info[o].LastName <<" "<<Info[o].Sex <<"
";
for (int p=0;p
<Nsubj;p++){
cout<<Data[p].Sub
<<" " <<Data[p].Point ;
}
cout<<endl;
};
getch ();
return 0;
} |