Answer to Question #286344 in C for Rupa

Question #286344

very urgent pls help me....

How to retrieve even lines(questions) and odd lines(answers(true/false)) from text file into 2D string array in C


1
Expert's answer
2022-01-11T09:44:33-0500
#include <string>
#include <fstream>

using namespace std;


int main()
{
    ifstream infile("quizfile.txt");
    string strings[10][10];
    int i = 0; 
    string line;
    while (std::getline(infile, line))
    {
        int row = i / 10;
        int col = i % 10;
        strings[row][col] = line;
        i++;
        if (i == 10 * 10)
        {
            break;
        }
    }


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS