DOUGLAS O. MOEN February 2016
Unable to reproduce problem ... code works as expected.
My Test (showing how I created "forwardCharStar);")
std::string forwardStr = "abcdefghijklmnopqrstuvwxyz";
size_t sz = forwardStr.size();
assert(sz < 100); // check fit
for (size_t i = sz-1; i < 100; ++i) forwardCharStar[i] = 0;
for (size_t i = 0; i < sz; ++i) forwardCharStar[i] = forwardStr[i];
std::string rS = reverseStr(forwardCharStar);
std::cout << "The reversed string is: " << rS << std::endl;
Note: filled tail of forwardCharStar with '\0'
- null terminator is important in c-style strings
Note: then transferred 26 chars from 'forwardStr' to front of forwardCharStar
The reversed string is: zyxwvutsrqponmlkjihgfedcba
Note: I commented out the char by char output from
2nd line of while loop
// std::cout << temp << std::endl;
Note: forwardCharStar matches the reversed string, the code modifies its input string.