Hi all
My friend sent me a source file that wrote hello world to a text file (im a noob), I tried to modify it and give myself a challange to make a small database but it has gone horribly wrong. I dont know how to get it so when the person enters n it goes back to the start of the program, but im also getting errors all over the shop.
Here are the error messages coming up, im using Dev C++ Beta 5.something
1)answer does not name a type
2)djout undeclared
3)unknown escape sequence /T
4)getline undeclared
5)answer undeclared
#include<fstream>// headerfile for output/input
#include<iostream>
#include<string>
using namespace std;
int main()
{
string personname;
string activity;
string arriving;
string answer
ofstream djout; // declare our djoutput
djout.open("C:\TEST.txt"); // opens/creates and edits "TEST.txt"
cout << "Please enter the persons name: ";
getline (cin, personname);
cout << "Please enter the activity: ";
getlline (cin, activity);
cout << "How are they arriving: ";
getline (cin, arriving);
cout << "Please confirm the details: ";
cout << "Name: " << personname << endl;
cout << "Activity: " << activity << endl;
cout << "Arriving by: " << arriving << endl;
cout << "Are the details correct? Y/N" << endl;
getline (cin, answer);
if (answer == 'y')
{
djout << personname << endl;
djout << activity << endl;
djout << arriving << endl;
djout.flush(); // to save the file, you must close the file, or flush
djout.close(); // the buffer to the file Closing the file will not let
// you access it anymore, so only call it when you are
// done using the file and it will automatically save
// the file for you. Flushing the buffer will write the
// buffer to the file and still keep the file open, so
// use this function when necessary.
}
if (answer == 'n')
{
//I want it to go back to the beginning of the program
}
else
{
cout << "System error sorry guys im not always right :)" << endl;
}
system("pause");
return 0;
}
Thanks for your help:)
HLA91