Uses getch() and putch() for char input and output. - C++ File Stream

C++ examples for File Stream:cin

Description

Uses getch() and putch() for char input and output.

Demo Code

#include <fstream>
#include <iostream>
using namespace std;
#include <conio.h>
void main()/*from   w w w.j  a v a  2 s  . c  o m*/
{
   int ctr;   
   char letters[5];   
   cout << "Please type five letters... \n";
   for (ctr = 0; ctr < 5; ctr++)
   {
      letters[ctr] = getch();    
   }
   for (ctr = 0; ctr < 5; ctr++) 
   {
      putch(letters[ ctr ]);
   }
   ofstream prn("PRN");
   for (ctr = 0; ctr < 5; ctr++) 
   {
      prn.put(letters[ ctr ]);
   }
   return;
}

Result


Related Tutorials