I am a new user and I am looking for some help with one of my problem. I have to write a program that reads in from a file through structs and store the information in a single struct and write the code to display a single class. This needs to be in a function that I am passing the struct to. Then modify the code so the class struct is stored in an array of structs, and finally write the code to display the information you have stored in a formatted screen output. My question is: how do i pass info a struct? How do i pass info into any array of structs? I would like some guidance with this problem. I am trying my best to understand what I need to :confused: . Below is my code any help would be greatly appreciated.
Thanks,
mathrules
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
// This struct hold information about the name of person, id number, phone #
struct Person
{
string name;
int iid;
int iphone;
};
// Struct tells what time the class is
struct Time
{
int iday;
int ihour;
int imin;
};
struct Course
{
string cname;
int icourseid;
};
//struct puts all information together and gives a concise output
struct Class
{
Person cstudent[50];
Person cinstructor;
Time itime;
string room;
Course curriculum;
};
int main ()
{
fstream information; // command to open file
Class * ptr;
ptr= new Class [70];
//Open the file
information.open ("lab05-mar.txt", ios:: in);
if (!information)
{ // Validate / Return Error if file won't open
cout<< " There is an error! Cannot open the file properly.";
return -1;
}
Class academic ;
void Totalinfo( fstream & information, something)
cout<<"How many classes do you have? " ;
cin << number;
cout<< number;
getline (information, academic.curriculum.cname);
cout<< academic.curriculum.cname << endl;
//getline(information,academic.curriculum.cname);\
cout << flush;
information >> academic.curriculum.icourseid;
cout<< academic.curriculum.icourseid;
return 0;
}