I'm trying to import this file
45256 Rodrigues Joana 58 75 58 61 59 75 63 92
37915 Wright Michelle 98 83 56 62 63 90 57 67
81984 Williams Jenny 55 67 54 63 89 84 93 75
73984 Phaneuf Lesley 78 85 57 51 68 94 51 83
80886 Laflamme Nicole 76 51 71 94 69 78 87 91
39473 Kenyon Patricia 65 54 90 68 94 70 95 97
12127 McCabe Kelly 51 96 0 64 54 75 71 94
52458 Whitten Sarah 99 58 94 82 81 75 82 70
77921 Connors Sarah 52 58 88 63 61 65 78 78
28810 Navin Joshua 94 75 62 93 64 92 87 94
31571 Toporowski Crystal 93 0 77 77 63 68 88 58
33580 Ziolko John 74 64 98 92 98 89 0 79
14508 Stronach Kurt 80 95 96 84 78 86 53 59
44520 Ecklord Ryan 0 61 56 86 98 98 59 83
15246 Berling Danielle 85 64 0 75 69 0 54 85
16137 Littlefield Arionna 71 85 74 97 69 64 82 95
62631 Niedojadlo Evan 73 66 83 97 97 51 66 88
59640 Knieriem Brandon 52 87 97 66 97 90 93 56
44102 Spence Arthur 85 84 100 82 91 0 95 62
42331 Rose Nicole 83 50 96 68 54 62 0 93
72054 Houde Jessica 72 66 71 62 75 71 86 100
24609 Cooper Camille 62 93 92 72 58 76 57 66
85736 Hepburn Spencer 71 0 62 60 52 62 64 51
87129 Morang Nicholas 77 67 57 89 88 64 68 78
43865 Hildebrandt Stephenson 97 94 93 93 82 88 78 100
78575 Suslovic Vikilynn 65 54 74 67 61 76 69 76
58751 Flores Jose 58 80 0 74 87 95 96 69
18140 Galotti Salvator 78 65 90 66 88 57 93 98
10364 Denaro Tony 73 85 55 72 68 91 55 89
99189 Vasquez Oskar 66 60 0 75 63 92 92 52
21705 Roy Jake 86 0 89 94 82 0 60 98
50838 Burr Jermiah 83 84 94 90 77 73 72 63
32998 Benway Eileen 76 98 80 69 75 94 77 95
87361 Perlmutter Diadre 96 60 81 88 81 53 91 74
into a structure with the following code:
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <cmath>
using namespace std;
struct student
{
int id;
string fname;
string lname;
int gr[6];
double avg;
char letGr;
};
void print(student arr[], int c)
{
cout << endl;
for (int i=1;1<=c;i++)
{
cout << setw(2) << i << ' ' << left << setw(10) << arr[i].id
<< arr[i].fname << arr[i].lname << right;
for (int j=1;j<=5;j++)
cout << setw(5) << arr[i].gr[j];
cout << setw(6) << arr[i].avg << setw(3) << arr[i].letGr << endl;
}
cout << endl;
}
void main()
{
ifstream inF;
student myStuds[20];
int cnt=0;
int id;
string fname, lname;
cout << fixed << setprecision(1);
inF.open("students.txt");
inF >> id;
while (!inF.eof())
{
cnt++;
myStuds[cnt].id = id;
myStuds[cnt].fname = fname;
myStuds[cnt].lname = lname;
for (int i = 1; i < 5; i++)
inF >> myStuds[cnt].gr[i];
myStuds[cnt].avg = 0.0;
myStuds[cnt].letGr = 'Y';
inF >> id;
}
inF.close();
cout << "Cnt = " << cnt << endl;
print (myStuds, cnt);
}
This compiles correctly, but when the dos screen comes up, the program immediately times out without an output....what's wrong?