Separating an input file into two multi-dimensional arrays

closed account (iEC9216C)
Hello, I am trying to take information from an input file "fileinp.txt" and separate it into two multidimensional arrays. The file in looks something like:

BABADABB
B000001ABCDCBDA
C000002BBCDACAB
B000003BAACBACA
B000004BABADDAB
B000005BABACDBB

Where the first is the answer key. I'm having trouble "cutting" the data into two fields, the first 7 characters are the i.d. and the remaining are their answers that must be checked against the first set of numbers, which is the answer key.
Here's what I have so far, again just need help on how to split the data so the program is unfinished:

#include <iostream>
#include <fstream>
using namespace std;
void numAs(double a)
{
//going to finish these functions when I know how to separate the data
}
void numBs(double b)
{

}
void numCs(double c)
{

}
void numDs(double d)
{

}
void numFs(double f)
{

}
void classAverage(double avg)
{

}
int main()
{
const int NUMSTUDENTS = 5;
const int KEY = 8;
char studentanswers[8][5];
char answers[KEY];
ifstream fin;
fin.open("fileinp.txt");
cout << "This program will process the test data from a file to show\n"
<< "the student's ID, their answers, test scores and test grades.\n";
for (int i = 0; i < KEY; i++)
{
fin >> answers[i];
cout << answers[i];
}
for (int i = 0; i < NUMSTUDENTS; i++)
{
cout << endl;
for (int i = 0; i < 1; i++)
{
fin >> studentanswers[i];
cout << "Student number is " << studentanswers[i];
}
}
cout << "Number of A's: " << endl; //I'm going to call function
cout << "Number of B's: " << endl; //""
cout << "Number of C's: " << endl; //""
cout << "Number of D's: " << endl; //""
cout << "Number of F's: " << endl; // ""
cout << "Class Average: " << endl; // ""
return 0;
}
Last edited on
Topic archived. No new replies allowed.