I would like to know how to store a modified string into an array of type char. Below is my code:
Code:
typedef char* ArrayPtr;
ArrayPtr array;
array = new char[1000];
istringstream break_apart(input);
while (break_apart >> word)
{
front = &word.at(0);
rear = &word.at(word.size() - 1);
while (front <= rear)
{
swap (*front, *rear);
front++;
rear--;
}
cout << word << " ";
}
for (int i = 0; i < input.length(); i++)
{
//WHAT DO I PUT HERE?!?
}
In the main part of the code there, I switched the positions of characters within the word to ultimately swap each word of 'input'. However, I need to store this modified string (originally 'input') into an array of type char. I know I have to use a for loop to copy it over, but what do I need to put inside the loop. I'm having trouble figuring this out... Thank you very much for all who help. I appreciate it!!!!
FYI - this post is simply a more specific version of my previous post. I solved the palindrome instance, so I'm simplifying so you all do not have to go through already solving info to receive the needed help.