write in a file

why isn't my computer showing anything in my file father??

#include "stdafx.h"
#include "iostream"
#include "fstream"
#include "string"
using namespace std;
fstream fatherfile;
void cfather ()
{
string father[100];
int y=0;
string x;
int s;
do
{
cout<<"write father names, -1 to stop";
cin >> x;
father[y]=x;
y++;
}
while ( x!= "stop" );
}

int main ()
{
int x;
cout<<" 1 to write the name of father \n";
cout<<" 2 to write the name of mother \n";
cout<<" 3 to write the name of kid \n";
cin >>x;
if ( x == 1 )
{
ofstream fatherfile;
fatherfile.open ("fathers.txt",ios::out | ios::app);
cfather();
fatherfile.close();
}
system("pause");
return 0;
}

Where do u write into file? I mean something like fatherfile << x;

What if I enter 101 lines of text? Program crashes.
Bucky has excellent basic tutorials on most things. Video 64-68 is about files.

https://www.youtube.com/playlist?list=PLAE85DE8440AA6B83

Watch them :)
Topic archived. No new replies allowed.