code for displaying text file not working

hello coders,
i have turbo c++ 3.0 installed .
my program is compiled without error and is running. but when i choose option to display scores in the consol , it hangs . please check my code. i have to run this on same compiler. i just want to display all the contenets of text file . help me.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<fstream.h>
#include<string.h>

void main()
{
clrscr();
int a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,o;
char n[30],p[20];
char* line;
cout<<"\n \t WELCOME TO BRAIN_CAFE QUIZ";
cout<<"\n RULES:THERE ARE 10 QUESTIONS WITH 4 OPTIONS";
cout<<"\n YOU HAVE TO CHOOSE ONE";
cout<<"\n ALL THE BEST";
cout<<"\n ENTER YOUR NAME AND PLACE:";
gets(n);
gets(p);
fstream myfile;
myfile.open("QUIZREC.txt",ios::app|ios::out|ios::in);
myfile<<"\n Player: \n";
myfile<<n<<"\n";
myfile<<p<<"\n";
clrscr();
cout<<"\n\n *****LETS START BRAINCAFE QUIZ***** \n";
cout<<"\n\nQ.1: THE WORDS 'SATYAMEV JAYATE' INSCRIBED BELOW THE BASE PLATE OF THE EMBLEM OF INDIA ARE TAKEN FROM .........";
cout<<"OPTIONS ARE \n 1.RIGVEDA \n 2.SATPATH BRAHMANA \n 3.MUNDAK UPANISHAD \n 4.RAMAYAN";
cin>>a1;
if(a1==3)
cout<<"RIGHT ANSWER";
else{
cout<<"THIS IS WRONG ANSWER \n THANKYOU FOR PLAYING BRAINCAFE QUIZ";
myfile<<"\n no correct answer"; goto jumphere;
}
clrscr();
cout<<"\n\nQ.2: WHICH OF THE FOLLOWING METALS FORMS AN AMALGAM WITH OTHER METALS?";
cout<<"\t OPTIONS ARE \n 1.MERCURY \n 2.TIN \n 3.LEAD \n 4.ZINC";
cin>>a2;
if(a2==1)
cout<<"RIGHT ANSWER";
else{
cout<<"THIS IS WRONG ANSWER \n THANKYOU FOR PLAYING BRAINCAFE QUIZ";
myfile<<"1 correct answer";goto jumphere;
}
clrscr();
jumphere:
myfile.close();
cout<<"\n\n\n DO YOU WANT TO SEE THE SCORES? \n PRESS 1 OR any other key \n";
cin>>o;
if (o==1)
{ ifstream infile("QUIZREC.txt");
infile.open ("QUIZREC.txt", ios::beg|ios::in);
while(!infile.eof())
{
infile>>line;
cout<<line;
}
infile.close();
}
cout<<"\n THANKYOU FOR PLAYING BRAINCAFE QUIZ";

getch();
}
Please use code tags when posting code, to make it readable.
how to do that i m new to this fouram
> how to do that i m new to this fouram

http://www.cplusplus.com/articles/jEywvCM9/


1
2
3
4
5
6
{
    cout << "\n\n\n DO YOU WANT TO SEE THE SCORES (1==YES)? " ;
    int answer ;
    cin >> answer ;
    if( answer == 1 ) cout << ifstream("QUIZREC.txt").rdbuf() ;
}
thankyou JLBorges. you solved my problem :)
Topic archived. No new replies allowed.