You aren't properly zero-terminating the C-style string.
Code:
#include <iostream>
#include <cstring>
using namespace std;
int main() {
char phrase[100], phrase2[100];
cin.getline(phrase, sizeof phrase);
cout << "The phrase you entered was: " << phrase << '\n';
size_t len = strlen(phrase);
for (size_t i = 0; i < len; ++i)
phrase2[i] = phrase[len - 1 - i];
phrase2[len] = '\0'; // zero-terminate the string
cout << "Phrase2 is: " << phrase2 << '\n';
return 0;
}
Of course, if you really want to write a C++ program then you should use C++ strings.
Code:
#include <iostream>
#include <string>
using namespace std;
int main() {
string phrase, phrase2;
getline(cin, phrase);
cout << "The phrase you entered was: " << phrase << '\n';
for (size_t i = 0; i < phrase.size(); ++i)
phrase2 += phrase[phrase.size() - 1 - i];
cout << "Phrase2 is: " << phrase2 << '\n';
return 0;
}