I Can't Build This Program.

Create a student database which is searchable by student ID.

You will create an array of structs, which will include First Name, Last Name, Student ID, GPA and Grade Level.

struct Students
{
string fname, lname;
long studentID;
int grade;
double GPA;
}

Students myStudents[10];

The data will be imported from a data file into an array (10 items, see attached file student1.txt)

User the fstream library
ifstream, ofstream,

Once data is imported into the array a menu will be displayed to the user to search for student ID or 0 (zero) the program, using a Do-While loop.

Use this code to open, read and close from file into array:
myFile.open("student1.txt");

while (myFile >> myStudents[index].first>>myStudents[index].last>> myStudents[index].studentID >> myStudents[index].grade >> myStudents[index].GPA )
{

index++;

}
myFile.close();

student1.txt -
Waldo Mccart 101 9 3.2
Eilene Gilkes 202 8 4.0
Fransisca Grullon 303 9 2.2
Mireya Brust 404 9 2.0
Kami Jeanlouis 505 7 3.5
Roosevelt Roussel 606 9 1.2
Lelah Drapeau 707 8 3.3
Fermin Phegley 808 9 2.9
Claud Mehaffey 909 8 2.8
Shantay Arroyo 110 9 2.2

Whatever help you can give me will be much appreciated.
Here is a program that compiles. Now add in all the stuff you need a piece at a time to make the program work. If you've already done more than this, please show your effort here.
1
2
3
4
5
6
7
8
#include <iostream>  //for printing a menu and getting a choice from the user
#include <fstream>   //for file I/O
#include <string>  //for strings like fname and lname

int main()
{
    return 0;
}
Topic archived. No new replies allowed.