C++ ifstream Read characters from File

Description

C++ ifstream Read characters from File

#include <fstream>
#include <iostream>
using namespace std;
int main()//  www  . j ava  2  s .  co m
{
   char ch;                       //character to read
   ifstream infile("TEST.TXT");   //create file for input
   while( infile )                //read until EOF or error
   {
      infile.get(ch);             //read character
      cout << ch;                 //display it
   }
   cout << endl;
   return 0;
}



PreviousNext

Related