Read characters from File - C++ File Stream

C++ examples for File Stream:stream

Description

Read characters from File

Demo Code

#include <fstream>
#include <iostream>
using namespace std;
int main()//  www .  j  a  v a 2  s. c  om
{
   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;
}

Result


Related Tutorials