Using GCC Compiler on Code::Blocks, I get an error:
Segmentation fault (core dumped)
Process returned 139 (0x8B)
...
After entering the input asked. Here's my test program:
#include <iostream>
#include <string>
using namespace std;
string getInput(string &input, string prompt)
{
cout << prompt;
getline(cin, input);
}
int main()
{
string input;
getInput(input, "What's your name?\n>");
cout << "Hello " << input << "!" << endl;
return 0;
}
What am I doing wrong, is the reference parameter being used incorrectly?