Reputation: 1638
char message[512];
string info;
...
// read from txt file and save to "info"
...
message = info.c_str();
The error is caused by "message" on the last line. I'm not familiar with C or C++, can someone tell me what went wrong?
Upvotes: 0
Views: 817
Reputation: 2627
You can do this:
strncpy(message, info.c_str(), sizeof(message));
message[sizeof(message) - 1] = '\0';
Upvotes: 1
Reputation: 19237
const char *message; // needs to be a pointer, not an actual array
string info;
...
// read from txt file and save to "info"
...
message = info.c_str();
Upvotes: 2