Thanks for your help with this. The best way that I can describe what this program is supposed to do is similar to the old "magic 8" balls, where you can ask a question that doesn't really matter and receive one of the pre-prepared messages. The only part of this that is still not working correctly is that what prompted for "would you like to ask another question", it does not allow for another question to be input and simply displays the second "answer", and the thrid, and so on.
The process should be input question, displays "answer", prompts for another question, if yes-displays another answer, if no-terminates program. Thanks again.
Code:
#include <fstream>
#include <iostream>
#include <cstdlib>
using namespace std;
using std::ifstream;
newLine(ifstream& fin);
int main()
{
char doesntmatter[100];
char question=0;
ifstream fin;
fin.open("A:\\answerfile.txt");
do
{
cout<<"Please enter a question:"<<endl;
cin.getline(doesntmatter, 100);
newLine(fin);
cout<<"Would you like to ask another question, y or no:"<<endl;
cin>>question;
}while(question=='y'||question=='Y');
return 0;
}
newLine(ifstream& fin)
{
char answerfile[100];
fin.getline(answerfile,100, '\n');
cout<<answerfile<<endl;
return 0;
}
The answerfile.txt file looks like:
Test answer one.
Test answer two.
Test answer three.
Test answer four.
Test answer five.