Advertisement
Felanpro

getchar() function c++

Nov 4th, 2015
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. //Example waits for a character input, then outputs the character
  2. #include <cstdio>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.   char a_char; //Declare char Variable.
  10.   a_char = getchar(); //set a_char variable to function getchar()
  11.   cout << a_char << " was the character you input." << endl;; //So when the user now inputs a chracter it will automatically print it out on the screen. :)
  12.   system("pause");
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement