当我发现需要在Ubuntu中运行时,我尝试将此代码从Visual Studio转移到Ubuntu中的Eclipse中。我已经删除了sdkddkver.h和tchar.h引用,因为我知道它们仅适用于Windows。我怎样才能摆脱这些错误(我假设它们源于为windows编写的错误)?
代码:
void encrypt(std::string &iostr, int key)
{
key %= 26;
int ch;
for (auto &it : iostr)
{
ch = tolower(it);
if (!islower(ch)) {
continue;
}
ch += key;
if (ch > 'z') {
ch -= 26;
}
it = ch;
}
}
int main()
{
string source;
int key = 1;
cout << "Paste cyphertext and press enter to shift each letter right 1 :";
getline(cin, source);
encrypt(source, key);
cout << source << "";
cout << "Press ENTER to exit";
cin.ignore(cin.rdbuf()->in_avail() + 1);
return 0;
}
在Eclipse中构建错误:../ test.cpp:13:7:警告:'auto'将改变C ++ 0x中的含义;请删除它[-Wc ++ 0x-compat] ../test.cpp:13:13:错误:ISO C ++禁止声明'it'没有类型[-fpermissive] ../test.cpp:13:18:错误:在C ++ 98模式下不允许使用基于范围的for循环 make:*** [test.o]错误1
我是Eclipse的新手,那么我可以针对这些错误做些什么改变呢?