Whenever i try that with this code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
#include<iostream>
#include<iostream>
#include<fstream>
#include<cstdio>
#include<cstring>
int main(){
const int numstudents = 100;
const int numquiz = 5;
const int numtest = 2;
const int numassignment = 4;
const int numletters = 30;
int tests[numstudents][numtest];
int quizzes[numstudents][numquiz];
int assignments[numstudents][numassignment];
char names[numstudents][numletters];
char buf[30];
int howmany = 0;
std::ifstream infile;
infile.open("gradebook.txt");
while(!infile.eof()){
infile.getline(buf, 30);
std::cout<<"hello ";
strcpy(names[howmany],buf);
for(int q = 0; q < 5; q++){
infile>>quizzes[howmany][q];
}
for(int t = 0; t < 2; t++){
infile>>tests[howmany][t];
}
for(int a = 0; a < 4; a++){
infile>>assignments[howmany][a];
}
howmany++;
}
infile.close();
std::cout<<"close"<<std::endl;
std::cout<<names[0]<<std::endl;
std::cout<<names[1]<<std::endl;
std::cout<<tests[1][0]<<std::endl;
std::cout<<tests[0][0];
return 0;
}
|
It gives me this:
hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello
hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello
hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello
hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello
hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello
hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello
hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello
hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello
hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello
hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello
hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello
hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello
hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello
hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello
hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello
hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello
hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello
hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello
hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello
hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello
hello hello hello
It loops 403 times and doesn't store or print the arrays or the close at the end of the program.