Dec 10, 2014 at 10:19pm UTC
Im trying to get my program to output the name from a file. The user should enter first name "or" last name. and if the user does not type the name from the input file. the get an error message. How do you do it
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;
const int NUM_STUDENTS = 17;
const int NUM_QUIZZES = 10;
const int NUM_EXAMS = 5;
struct student
{
string firstName;
string lastName;
int quizzes[NUM_QUIZZES];
int exams[NUM_EXAMS];
};
int main()
{
student Evaluation[NUM_STUDENTS];
ifstream inStream;
inStream.open("xxxxx");
for (int index = 0; index < NUM_STUDENTS; index++)
{
cout << "Enter student's first name: ";
inStream >> Evaluation[index].firstName;
cout << "Enter student's last name: ";
inStream >> Evaluation[index].lastName;
if(!inStream)
{
cout << "The name you have entered does not appear on the list" << endl;
}
}
system("pause");
return 0;
}
Last edited on Dec 10, 2014 at 10:19pm UTC
Dec 11, 2014 at 12:42am UTC
can you please help? im still a beginner
Dec 11, 2014 at 1:53am UTC
its an array of structure code