0

I tried to transfer this codefrom Visual Studio into Eclipse in Ubuntu when I found out it needed to just run in Ubuntu. I already removed sdkddkver.h and tchar.h references, as I understand they are for Windows only. How can I get rid of these few errors(I'm assuming they are stemming from this being written in for windows)?

Code:

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;

}

Build errors in Eclipse: ../test.cpp:13:7: warning: ‘auto’ will change meaning in C++0x; please remove it [-Wc++0x-compat] ../test.cpp:13:13: error: ISO C++ forbids declaration of ‘it’ with no type [-fpermissive] ../test.cpp:13:18: error: range-based-for loops are not allowed in C++98 mode make: *** [test.o] Error 1

I'm new to Eclipse, so what can I change for these errors?

NathanOliver
  • 171,901
  • 28
  • 288
  • 402
bert0nius
  • 17
  • 5

0 Answers0