我希望用户输入strrev的字符串来反转但是当用户输入字符串空格时由于某种原因是不允许的,所以如果有人输入你好我的名字是stan.输出只是nats,我怎样才能获得接受空格的功能?
#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;
}
Run Code Online (Sandbox Code Playgroud)
strrev是一个已弃用的函数,仅在Microsoft工具链中可用,不应使用.你可以反向字符串std::reverse.
| 归档时间: |
|
| 查看次数: |
594 次 |
| 最近记录: |