Need help ASAP Plz
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Need help ASAP Plz

  1. #1
    Join Date
    May 2009
    Location
    Muscat, Oman
    Posts
    2

    Exclamation 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! ):

    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
    Last edited by gti_freak; May 9th, 2009 at 06:37 AM. Reason: enhancin

  2. #2
    Join Date
    May 2009
    Location
    Muscat, Oman
    Posts
    2

    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!
    Last edited by gti_freak; May 9th, 2009 at 06:44 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center