please guide me as to why this code isn't workong

here's the code:
#include<iostream>
#include<string.h>
#include<fstream>
using namespace std;
int main()
{
const int size = 50;
char string[size];
cout<<"Enter string:";
cin>>string;

int len = strlen(string);
fstream file;
file.open("text",ios::in|ios::out);
for(int i = 0;i<len;i++)
{
file.put(string[i]);
}
cout<<"output : "; //<-problem from here
file.seekg(0);
char ch;


if(file.eof() !=0 )

{
file.get(ch);
cout<<ch;
exit (1);
}

file.close();
cout<<endl;
system("pause");
return 0;
}


Last edited on
Use [code][/code] tags and tell us what the errors and/or problems are, please.
okay the problem with this is that whenever you enter a string ...and press enter, the control skips the code after the output statement as shown above..it displays the message" output: "
but there is no actual output and then the program terminates.
Topic archived. No new replies allowed.