Skip to content

Instantly share code, notes, and snippets.

@AndyNovo
Last active April 4, 2021 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save AndyNovo/b3447d92c61b8f1c5506 to your computer and use it in GitHub Desktop.
Save AndyNovo/b3447d92c61b8f1c5506 to your computer and use it in GitHub Desktop.
A simple function example
#include<iostream>
using namespace std;
string prompt_user(string input_prompt){
string reply;
cout << input_prompt << endl;
cin >> reply; //only use one of these two lines.
//getline(cin, reply);
return reply;
};
int main(){
string response = prompt_user("How are you doing today?");
cout << "You said: " << response << endl;
response = prompt_user("Is it your birthday?");
cout << "You said: " << response << endl;
return 0;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment