Prints a name on the printer. - C++ File Stream

C++ examples for File Stream:stream

Description

Prints a name on the printer.

Demo Code

#include <fstream>
#include <iostream>
using namespace std;
void main()// ww  w . j ava  2  s . c  om
{
   char first[20];
   char last[20];
   cout << "What is your first name? ";
   cin >> first;
   cout << "What is your last name? ";
   cin >> last;
   // Send names to the printer.
   ofstream prn("PRN");
   prn << "In a phone book, your name looks like this: \n";
   prn << last << ", " << first << "\n";
   return;
}

Result


Related Tutorials