-
Need help ASAP Plz
i have a text file containing this:
acbdaadcbdabdcb
abdaadcbbddbccb Ahmed Suliman
acbdacbccdabdcb Mohammed Khalifa
acbdaadcbaabdcb Saeed Nasser
dbcacddbbbacccc Amal Mansoor
acbddaadcdabddd Zayed Moosa
acbdddddbcabdcc Mohanned Ibrahim
abcacccbbbdddcb Omer Hamdan
acaaaaacbaccdcb Salim Ali
aaadaacccbabdcb Mona Fadhel
abcabcdaacabdcb Saif Salim
and i need to do this (and i have no idea how to! :confused:):
1. Load Answers: reads the exam data from the input file “exam.txt” into three program array variables:
- Array correct[]: an array of 15 characters that stores the first line containing the correct exam answers.
- Array answer[]: an array of 10 string values storing each student exam answer as a string value.
- Array name[]: an array of 10 string values storing each student full name as a string value.
- This option is implemented using the function LoadAnswers(…) that fills and returns the correct answer,
student answer and student name arrays. Tip: you may use <cstring> strcpy() member function and <string>
c_str() member function.
Plz help ASAP
-
Re: Need help ASAP Plz
all i got so far is this:
int LoadAnswers()
{
const int size = 14;
string answer[10], name[10], vanswer, vname1, vname2;
char ch, correct[size];
int i(0), ii(0);
ifstream fin("exam.txt");
if (fin.fail())
{
cerr<<"Could not open input file (exam.txt)\n";
exit(1);
}
while(fin.get(ch))
{
correct[i] = ch;
if (i == size) break;
++i;
}
while(!fin.eof())
{
fin>>vanswer>>vname1>>vname2;
answer[ii] = vanswer;
name[ii] = vname1 + " " + vname2;
++ii;
}
return 0;
}
IT IS NOT WORKING!