I am looking to access a completely random line of a small text file, and import the same line in another text file in a C++ program. I need to do this fairly simply, I am a beginner to C++ programming. I will include main.cpp
. If you need the other .cpp
or the .h
, just let me know, I will post it.
Main.cpp:
#include <fstream>
#include <iomanip>
#include <iostream>
#include <cmath>
#include <ctime>
#include <string>
#include <vector>
#include "getQuestion.h"
using namespace std;
int main() {
int mainMenuChoice;
ifstream Bibliography;
//string easyBib;
string easyBib;
ifstream inputFile;
cout << "Quiz Menu\n\n";
cout << "1. Play Game!\n";
cout << "2. Bibliography\n";
cout << "3. Developer Info\n";
//cout << "4. Admin Menu\n";
cout << "4. Exit\n";
cout << "Menu Choice: ";
cin >> mainMenuChoice;
switch (mainMenuChoice) {
case 1:
//int getQuestion(string Q,A);
//cout << Q;
break;
case 2:
inputFile.open("Bib.rtf");
inputFile >> easyBib;
cout << easyBib << endl;
break;
case 3:
cout << "Program made by: XXXX XXXXXXXX" << endl;
cout << "XXX. XXXXXXX'X Period 4 Social Studies Class" << endl;
break;
/*case 4:
break;*/
case 4:
cout << "Thank you for playing!" << endl;
return(0);
default:
cout << "Sorry, Invalid Choice!\n";
return(0);
}
return(0);
}