Monday, January 30, 2012

Write a C++ program that鈥檚 simulates the game of Jeopardy. You should use a text file to read in the answers

im not asking for someone to do this for me (though u can if u want :) but in all seriousness i need a boost in terms of writing the code to read from text file and array the rest i can figure out myselfWrite a C++ program that鈥檚 simulates the game of Jeopardy. You should use a text file to read in the answers
You should probably add some error handling but this code will work fine if everything is set up perfectly (e.g. the file(s) exist, file data is correct, etc.). Here's a start:



#include%26lt;iostream%26gt;

#include%26lt;string%26gt;

#include%26lt;fstream%26gt;

using namespace std;



const int TotalRows = 50;



int main()



{



ifstream inFile;



string answer_array[TotalRows];



inFile.open( "JeopardyAnswers.txt" );



int location = 0, linecount = 0 ;



while ( linecount %26lt; TotalRows )

{

getline(inFile, answer_array[linecount]);



linecount++;

}

inFile.close();



}

No comments:

Post a Comment