How do I take a c string and input it into a char* array? Basically I want to take a few sentences and add them one at a time into a char array.
1 2 3 4 5 6
string str1 = "This is a test sentence";
string str2 = "Middle sentence goes here";
string str3 = "End sentence";
//I actually have a loop to collect input and convert each
//string to a c_string but that's not relevant to my issue.
I want to put sentence 1 in the char*, then the second, then the third.
I tried something like this:
*userInputArray = *userInputArray + str1;
Now I know that won't work but I'm not sure what I can do to accomplish this goal.
It's for an assignment. I'm not sure what I'm doing and have been having a hard time wrapping my brain around the assignment. He wants us to create a buffer that contains three sentences as described up above and wants us to use pointers to display the sentences back to the user in reverse order. I guess the char* is to house the addresses of where each sentence starts in the buffer? What should I use as a buffer a char array separating each sentence with a null?