Read and output letter - C++ File Stream

C++ examples for File Stream:cin

Description

Read and output letter

Demo Code

#include <fstream>
#include <iostream>
using namespace std;
void main()/*from w ww . j  ava2 s .co  m*/
{
   char  in_char;     
   char first, last;  
   cout << "What is your first name initial? ";
   cin.get(in_char);  
   first = in_char;
   cin.get(in_char);  
   cout << "What is your last name initial? ";
   cin.get(in_char);  
   last = in_char;
   cin.get(in_char);  
   cout << "\nHere they are: \n";
   cout.put(first);
   cout.put(last);
   return;
}

Result


Related Tutorials