0

so recently i set up a VM and installed VS2012 Professional and my c++ code is not working on this one

But on the local machine ive written this C++ code on VS2013 for windows desktop Express

#include<iostream>
#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;


int main(){

    ofstream myfile;
    myfile.open("example1.csv");

    vector<int> cats;
    cats = { 1, 2, 3, 4, 5 };
    sort(cats.begin(), cats.end());
    do {

        for (int j = 0; j<cats.size(); j++){

            cout << cats[j] << ',';
            myfile << cats[j] << ',';

        }


        cout << endl;
        myfile << endl;

    } while (next_permutation(cats.begin(), cats.end()));

    myfile.close();

    return 0;

}

this basically should just get me the permutation of the vector declared but im getting this error in VS2012 Pro

-error C2059: syntax error: '{'
-error C2143: syntax error: missing ';' before '{'
-error C2143: syntax error: missing ';' before '}'
-IntelliSence: expected an expression
-warning C4018 '<':signed/unsigned mismatch 
Noopty
  • 13
  • 1
  • 4

1 Answers1

0

Visual Studio's C++11 support is spotty. Visual Studio 2012, for example, doesn't support initializer lists like this one:

cats = { 1, 2, 3, 4, 5 };

Visual Studio 2013 does, so they're catching up. Anyway, your code works in VS2013 and not in VS2012 because 2013 added more functionality.

Here's a list of what is and isn't supported by version.

And welcome to my hell. I have to use Visual Studio 2010. I'm lucky to compile stuff from the 2003 standard. I'm lucky to compile stuff from the 90's. Please, God, let me upgrade!

user4581301
  • 33,082
  • 7
  • 33
  • 54