Let me tell you something. You cut a part of your code and put it here, and when we try to figure out what's wrong, we are totally lost. hehehe, seriously!
But, first of all, it's "Outfile.close" not "Outfile.Close".
Second of all, There is nothing wrong with your code. But here are some pointers:
* Try to delete the Student.txt from your folder and run the program that I copied here and see the result.
* You explained why you used app, so beware of the outcome.
* You don't write your variables name like the way you do in human language. What I mean is, there are some conventions that you should follow. As far as I know, System Programmers and Unix programmers, use "_" kind of format, Like:
int pointer_to_file;
But Object oriented programmers and framework programmers use FIRST SMALL, REST BIG(I just made it up!!!). Means it's gonna be like:
int pointerToFile;
It's up to you how to use it, but I think you'd better at least follow a convention to give some professional look to your program. Professionals, please correct me if I'm wrong.
And after all the story here goes the code, just copy and paste it and compile...
#include <fstream>
using namespace std;
void WriteToFile();
int main()
{
WriteToFile();
return 0;
}
void WriteToFile()
{
int Count = 10, StudentNo = 102211;
string Name = "Tom", Surname = "Hanks", Gender = "Male", DateOfBirth = "8/14/2009";
double Mark = 15.5;
ofstream Outfile;
Outfile.open("Student.txt", ios::app);
Outfile << Count << endl;
Outfile << StudentNo << endl;
Outfile << Name << endl;
Outfile << Surname << endl;
Outfile << Gender << endl;
Outfile << DateOfBirth << endl;
Outfile << Mark << endl;
Outfile.close();
}