Click here to Skip to main content
15,904,494 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
#include<iostream>
#include<fstream>
#include<conio.h>

using namespace std;

int main()
{
	char InFile[80]; 
	char ch;
	
	ifstream InStream;

	cout<<"Enter input file name: " ;
	cin>>InFile;

	//open the file
	// in.open(fin); 
	InStream.open(InFile, ios::in);

	// check the file
	if(!InStream)
	{
		cout << "Error open file " << InFile << endl;
	getch();
		//system("pause");
	}
	
	cout << "Here is the content of " << InFile << ": ";
	while (!InStream.eof()) {
		//Read each character.
		InStream.get(ch);    

		// make sure we don't write any odd characters on screen
		if (!InStream.eof()) 
		{
			cout << ch;  //Write to screen
		getch();
        //	system("pause");
		}
	}

	InStream.close();
}




------------
the problem is that,yes the content in the file will shown up but letter by letter evrey after i entered..please help me to fix with this ..
Posted
Updated 10-Jan-12 7:18am
v2
Comments
Albert Holguin 10-Jan-12 13:19pm    
What's your question? ...it's not clear...
reikuxian 10-Jan-12 13:25pm    
the problem is that,yes the content in the file will shown up but letter by letter evrey after i entered..please help me to fix with this ..

the output should be like this..
"Here is the content of (the content of the text file)like i am awesome
-----
but in my own output
"Here is the content of (the content of the text file): i [enter in keyboard] a [enter again] m [enter again]

my problem is the content will appaer letter by letter every after enter not automatically shown the content of the text file..
Albert Holguin 10-Jan-12 13:33pm    
See solution 1 posted below.
reikuxian 10-Jan-12 13:46pm    
can you please help with the other code i'm having difficult to fix all the error...im bit confused about it..

1 solution

You have a getch() in while loop !
 
Share this answer
 
Comments
Albert Holguin 10-Jan-12 13:33pm    
yep... that'll do it... just get rid of that getch(), it's trying to get input from the std input (keyboard)... +5
reikuxian 10-Jan-12 13:36pm    
thankyou :) i solved with your help

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900