Now thats intereting! After doing some research, I learned that the cin command only accepts inputs up to a space. Anything after the space gets stored in memory and is automatically applied to the next cin. This is why the program kept looping when I entered something with spaces in it. I solved the problem by using cin.getline along with cin.clear and cin.ignore.
Code:
#include <iostream>
#include <fstream>
#include <limits>
using namespace std;
main ()
{
char question[200];
int x;
ofstream a_file("test.txt",ios::app);
do
{
cout<<"Enter a question:\n\n";
std::cin.getline(question,200);
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
a_file<<question<<"\n";
cout<<"Would you like to enter another question?\n";
cout<<"1 for yes. 2 for no: ";
cin>>x;
}
while (x!=2);
a_file.close();
cout<<"Your submition has been saved. Have a nice day!\n";
cout<<"Press enter to close the program.";
cin.get();
}
But there is still the problem of the code outside the loop not executing when the loop is terminated. I'll keep looking and post the answer here for anyone else who needs it.