【发布时间】:2018-09-05 04:07:06
【问题描述】:
#include <iostream>
using namespace std;
int main()
{
string message;
cout << "Ahlan ya user ya habibi." <<endl;
cout <<"what do you like to do today?" <<endl;
cout <<"please enter the message:" <<endl;
getline(cin,message);
for(int i=0;i<message.size();i++)
{
if(string(message[i]==32))
{
cout<<char(message[i]);
}
else if(string( message[i])>=110)
{
int x = int(message[i])-13;
cout<<char(x);
}
else
{
int x = string (message[i])+13;
cout<<char(x);
}
}
return 0;
}
E:\my programe\quiz\main.cpp|20|error: no matching function for call to 'std::__cxx11::basic_string
::basic_string(char&)'| E:\my programe\quiz\main.cpp|20|错误:从 'char' 到 'const char*' 的无效转换 [-fpermissive]|
E:\my programe\quiz\main.cpp|27|error: no matching function for call to 'std::__cxx11::basic_string
::basic_string(char&)'| E:\my programe\quiz\main.cpp|27|错误:从 'char' 到 'const char*' 的无效转换 [-fpermissive]|
【问题讨论】:
-
这没什么大不了的,但除了答案的反馈之外,您应该考虑只使用
'n'和' '而不是表示这些值的整数,因为它使您的代码更具可读性
标签: c++