Can't figure out pointersto save my life

So I can't comprehend pointers and their use to save my life. I want to pass the variable message through get_line() so the user can input a string and then use it later on down in main(). Every time I print the string message after get_line, it loses whatever was stored in it and it prints nothing to the screen. I could use & I suppose but my professor says we must use pointers. Thanks in advance!

#include <stdio.h>
#include <string>
#include <iostream>

using namespace std;


void get_line(string *line){
string reply;
cout << "Please enter a string: " << endl;
getline(cin, reply);
reply=*line;
}
int main()
{
string message, coded;
get_line(&message);
cout << "Your message is: " << message << endl;
return 0;
}
This assignment statement is the wrong way round,
 
    reply = *line;
it should be
 
    *line = reply;


Though variable reply is not needed. Just use the parameter directly:
1
2
3
4
5
void get_line(string *line)
{
    cout << "Please enter a string: " << endl;
    getline(cin, *line);
}

Topic archived. No new replies allowed.