hi guys,
i'm just trying to read in a file and output it chracter by character, the problem is i get an extra output of the last character, why does it still go through my loop when the condition has been met, also is there any way i can make this code more efficient:
#include <iostream>
#include <fstream>
using namespace std ;
int main(void)
{
ifstream inFile ;
char strFileName[10] ;
char chFileCharacter ;
cout << "Please enter filename: " ;
cin >> strFileName;
inFile.open(strFileName);
if (!inFile)
{
cout << "File not found" << endl ;
}
while (!inFile.eof())
{
inFile >> chFileCharacter ;
cout << chFileCharacter ;
}
inFile.close();
return 0 ;
}
oh yeah, one other thing, why can't i use a string variable rather than a char array to open a file, it gave me a funny error.
Thanks guys.