Hello.
I've been having trouble with this code for the last few days now. While I've finally managed to get it to the state where it compiles without an error message, I haven't been able to actually get the output to what is needed.
Here is my code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
using namespace std;
int main()
{
fstream fWrite;
cout << " ========================" << endl;
cout << " Exam Question Creation";
cout << "\n ========================" << endl;
std::cout << "\n\n";
ofstream outputFile;
char fileName[32];
char question[71];
char ch;
cout << "\n Enter the name of the file to be used: ";
cin >> fileName;
string que;
char ans;
ofstream otp_file;
otp_file.open("DMVexam.txt", ios_base::app);
int c = 1;
while (c == 1)
{
cout << "\n Enter a YES/NO question (in one line, no more than 70 characters):" << endl;
getline(cin, que);
cout << " Enter Your Answer(Y/N):";
cin >> ans;
otp_file << que << "\n";
otp_file << ans << "\n";
outputFile.close();
getchar();
cout << " To continue, enter 1. To exit, enter 0. " << endl;
cin >> c;
cin.ignore();
}
otp_file.close();
}
|
However, the problem is that is where I'm stuck.
Below is what I'm trying to make it look like.
Exam Question Creation
========================
Enter the name of the file to be used: question.txt
Enter a Yes/No question (in one line, no more than 70 characters):Are there rules on 'turn on red light'?
Enter answer (Y or N): Y
Do you have more question to enter (Y or N): y
Enter a Yes/No question (in one line, no more than 70 characters): Do you need a license to drive?
Enter answer (Y or N): Y
Do you have more question to enter (Y or N): y
11 questions were added this run.
Thank you for using my program!!
PROGRAMMER: Zeke Armstrong
CMSC140 Common Project 3
Due Date: 10/28/2018
Program ended with exit code: 0
Instead of it coming out like that, I can't seem to get the actual question bit to run correctly and it just skips right over into the Y/N answer part and even then, I'm not sure where to go from there.
Any help would seriously be appreciated.
THANK YOU.