Code:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
char text[100];
char choice[100];
int finish = 0;
cout<<"Moongoose's bibliography writing program\n";
cout<<"A html file will be written containing your bibliography.\n";
ofstream page("bibliography.html");
page<<"<html><body><h1><b><marquee behavior = 'alternate'> Moongoose's Bibliography writing program!!</marquee></b></h1>\n";
int count=1;
while (finish == 0 && finish != 1)
{
page<<"<br>";
cout<<"MENU:\nType in the number next to want you want to do\n1. Add a book to your bibliography\n2. finish\n";
cin.getline(choice,100);
int k=atoi(choice);//Use it to convert to integers
//Or You could just validate the
//input using a string
if (k == 1)
{
cout<<"What is the author's last name?\n";
cin.getline(text,100);
page<<count<<"."<<text<<", ";
cout<<"What is the author's initial?\n";
cin.getline(text,100);
page<<text<<". ";
cout<<"What year was it first published in?\n";
cin.getline(text,100);
page<<"("<<text<<"), ";
cout<<"What is the book called?\n";
cin.getline(text,100);
page<<"<i>"<<text<<"</i>. ";
cout<<"Where was it published? If your not sure check the back of the book and covers\n";
cin.getline(text,100);
page<<text<<": ";
cout<<"Who is the publisher?\n";
cin.getline(text,100);
page<<text<<".";
count++;
}
if (k == 2)
{
finish = 1;
}
}
page<<"</body></html>";
page.close();
cout<<"Your bibliography is complete, you can now copy and paste or do whatever with the page that has been created\n";
cin.get();
cin.get();
}
I'm not sure if you've already done this but if you're using getline you may encounter problems when reading in ints. This should solve your problem, although there are other ways as well, yada yada yada.