This might be a very basic c/c++ question, but I am really struggeling at it right now.

I have a struct that looks something like this:

```
struct connection_details {
    const char *server, *user, *password, *database, *mysql_port, *ssh_port;
};

```

And I have the data in a seperate text file.
So I would like to write a function, that takes a pointer to the struct, to write each line of the text file to the corresponding variable of the struct.

```
void get_config(const std::string &config_path, connection_details *mysql) {
    ifstream file(config_path);
    string str;

    getline(file, str);
    mysql->user = str.c_str();
    getline(file, str);
    mysql->server = str.c_str();
    getline(file, str);
    mysql->database = str.c_str();
    //...
    file.close();
}

```

But now the char pointer points to a variable that no longer exists, and even if it still existed, every part of the struct would point to the same variabe, not the content it was supposed to be.

I know this is a rather basic question, but I came to the point where I don't now what to google anymore, so every help is welcome.