C++ cin read char array as string

Description

C++ cin read char array as string

#include <iostream>
using namespace std;
#include <iomanip.h>
int main()/*from www.  jav a2s  .co  m*/
{
   char first[20], last[20];
   cout << "What is your first name? ";
   cin >> first;
   cout << "What is your last name? ";
   cin >> last;
   cout << "\n\n";     // Prints two blank lines.
   cout << "In a phone book, your name would look like this:\n";
   cout << last << ", " << first;
   return 0;
}



PreviousNext

Related