I have tried in vain to find a solution to my problem. Any help is much appreciated.
I installed Mingw a while ago in an effort to begin coding without an IDE. I am trying to learn C++ and a file that I have wont compile. The file is a .cpp file that is part of an online course I am taking and compiles successfully in Visual Studio 2015, but not with the standard g++ command I use to compile within cmd.
Here is the code:
#include <cstdio>
using namespace std;
int main( int argc, char ** argv )
{
int ia[] = { 1, 2, 3, 4, 5 };
for( auto i : ia ) {
printf("i is %d\n", i);
}
return 0;
}
When I try compiling, the command prompt returns the following:
cpp112.cpp: In function 'int main(int, char**)':
cpp112.cpp:9:15: error: 'i' does not name a type
for( auto i : ia ) {
^
I thought it could be that my compiler was out of date, but no updates showed when I opened the MinGW install gui.
Again, thank you for your assistance. I am out of ideas.
Aucun commentaire:
Enregistrer un commentaire