This is my program for printing a file using c++ program.
This gets complied and linked properly.
but when i run it , then it does not print anything.
its OUTPUT
Input file opened
OUTPUT file opened
in of loop
in of loop
in of loop
in of loop
in of loop (it gets printed equal to the number of chars in the file)
out of loop
then it gets hanged...
where is the problem ????
Code:
#include<iostream>
#include<fstream>
#include<conio.h>
void main()
{
char ch;
ifstream infile("tem.txt");
if(!infile)
{
cout<<"error in opening the input file";
getch();
}
else
{
cout<<"Input file opened\n";
}
ofstream outfile("PRN");
if(!outfile)
{
cout<<"error in opening the output file";
getch();
}
else
{
cout<<"OUTPUT file opened\n";
}
while(infile.get(ch)!=0)
{
cout<<" \n in of loop"
outfile.put(ch);
}
cout<<" out of loop";
}
where is the problem???