使用 strrev 在 C++ 中正确反转字符串

Properly reversing a string in C++ using strrev

我希望用户输入 strrev 的字符串来反转,但是当用户输入字符串时 space 出于某种原因不允许,所以如果有人输入 hello,我的名字是 stan。输出只有 nats,我怎样才能得到接受白色的函数 space?

#include<iostream>
#include <cstring>
#include<string.h>
using namespace std;
int main()
{
    char str[] = "This is a c-StyleString";
    //cout <<"Enter the string:" << endl;
    //cin >> str;
    cout << "Reverse of the given string is: " << strrev(str);
    return 0;
}

strrev 是一个已弃用的函数,它仅在 Microsoft 工具链中可用,不应使用。您可以使用 std::reverse.

反转字符串