C++ ifstream get() Read one character

Description

C++ ifstream get() Read one character

#include <fstream>
#include <iostream>
using namespace std;
int main()//from w  w  w  .  ja  v a2 s.c o  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