Skip to content

Commit

Permalink
getline
Browse files Browse the repository at this point in the history
This program is used to learn how to use the getline
  • Loading branch information
feihun1 committed Apr 1, 2017
1 parent 2f33d2d commit 271aa87
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions cpp two.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//The use of the getline:
#include <iostream>
int main()
{
using namespace std;
char ch1[10],ch2[5];
char ch;
int a;
cout << "What is your first name?";
cin.getline(ch1, 10); //getline to "Enter" as a symbol of the end of the input
cout << endl<<"What is your last name?";
cin.getline(ch2, 5);
cout << endl << "What letter grade do you deserve?";
cin >> ch;
cin.get();
cout << endl << "What is your age?";
cin >> a;
cin.get();
cout << endl << "Name:" << ch1 <<" "<< ch2<<endl;
cout << "Grade:" << char(ch + 1)<<endl;
cout << "Age:" << a;
cin.get();
return 0;
}

0 comments on commit 271aa87

Please sign in to comment.