Question: c++ Programming, Read data from file store utilizing structs and display each question read from file! #include #include #include #include #include #include using namespace std;

c++ Programming, Read data from file store utilizing structs and display each question read from file!

#include

#include

#include

#include

#include

#include

using namespace std;

#define NUM_CHOICES 4

struct Choices {

string text[4];

string answer;

bool shuffle;

};

Struct Questions {

string ID;

string text;

Choices choices;

int points;

};

// This function reads all the questions from sampledata.txt and returns the amount of questions in the file! , Count will go up by one everytime an ID is read. Data reading is stopped by END

int readQuestions (Questions questionchoices[]) {

return 0;

}

// This function displays the contents of a question.

void displayQuestion (Questions questionschoices[], int num) {

}

int main () {

// Declarations for questionchoices

Question questionchoices[100];

int numQuestions;

return 0;

}

sampledata.txt

c++ Programming, Read data from file store utilizing structs and display each

Getline to be used where necessary!

question read from file! #include #include #include #include #include #include using namespace

Placement You are third place in a race. What place are you in if you pass the person in 1st place? 1st 2nd 3rd None of the above 2nd 0 1 Days How many months have 30 days? 2 1 None of the above. Depends if there's a leap year or not. None of the above. 0 1 ID OF QUESTION QUESTION? CHOICE 1 CHOICE 2 CHOICE 3 CHOICE 4 CORRECT ANSWER SHUFFLE RESPONSE MARK AWARDED Dead A farmer has 17 chickens, all of them but 8 die. How many chickens are still standing? 8 9 25 35 8 1 1 END Reading a String with Spaces The getline function can be used to read a string containing spaces. It reads all the characters in a line. Suppose input file is an ifstream that has already been opened and line is a string. The getline function can be used to read all the characters from the next line of input in the file into line: ifstream inputFile; string line; getline (inputFile, line)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!