program is checking for ent when user inputs out?
What is wrong with this code?
It is fout-ing to the file fine, but when inputing string out, it checks for ent, so you can't us anything with i, u, b, e, q, d, or c in it, or any spaces. Help!
Code:
#include <iostream>
#include <fstream>
#include <conio.h>
#include <string>
using namespace std;
char ent;
char in[100];
char defi[100];
char defi2[100];
char name[100];
string out;
char ext[100];
char open[100];
char close[100];
int main()
{
cout << "Welcome to BDCPP! Name your file:\n";
cin >> name;
ofstream fout(name);
fout <<"//" <<name<<" created in BDCPP\n";
cout << name << " created\n";
getch();
while (ent != 'q')
{
system ("cls");
cout << "Enter:\n";
cin >> ent;
if (ent == 'd')
{
cout << "Define what?\nEnter:\n";
cin >> defi;
cout << "Define "<< defi<<" as:\n";
cin >> defi2;
fout << "#define "<<defi<<" " << defi2<< ";\n";
cout << defi << " defined";
getch();
}
else if (ent == 'c')
{
cout << "Char what?\nEnter:\n";
cin >> in;
fout << "char "<< in<<";\n";
cout << in << " chared";
getch();
}
else if (ent =='u')
{
cout << "Using namespace std.\n";
fout << "using namespace std;\n";
getch();
}
else if (ent == 'i')
{
cout << "Include what?\nEnter:\n";
cin >> in;
fout << "#include <" << in << ">\n";
cout << in << " included\n";
getch();
}
else if (ent == 'b')
{
cout << "Opening int main\n";
fout << "int main()\n";
fout << "{\n";
getch();
}
else if (ent == 'o')
{
cout << "Output what?\nEnter:\n";
cin >> out;
fout << "cout << \"" << out<<"\\n;"<<"\n";
getch();
}
else if (ent == 'e')
{
cout << "Closing main()\n";
fout << "}\n";
getch();
}
}
}
Thanks in advanced.