mardi 2 juin 2015

Code::Blocks Issue; "It seems that this project has not been built yet. Do you want to build it now?"

I write my code, it builds fine (no errors or warnings), then I hit "run" and it asks what I got in the title. I hit yes, then it asks it again. I hit yet, and nothing happens.

The strange thing is, my code works perfectly fine in Visual Studio. The code is meant to print a 3x3 grid to the console, like this:

123
456
789

The code is very simple:

int main()
{
    int arrayTest[3][3] =
{
    {1,2,3},
    {4,5,6},
    {7,8,9}
};
for (int j = 0; j < 3 ; j++)
{
    for(int i = 0; i < 3 ; i++)
    {
        cout << arrayTest[j][i];
    }

  cout << endl;
}
return 0;
}

The issue I find (In this case), is line 13 (Though no errors show). I can change line 13 a little bit and it works, but no changes are needed in Visual Studio.

 //Option one:
cout << arrayTest[j][i] << "";

Notice it works fine as soon as I simply add << ""; on the end of the line. Then it runs as expected.

//Option two:
cout << arrayTest[j][i];
cout.flush();

Adding cout.flush(); stops the issue from happening also.

Also removing

cout << endl;

From line 16 works too. So does anyone know why I am getting such specific issues?

Additional info:

OS: Windows 8.1 IDE: Code::Blocks Compiler: MinGW (The one that comes with Code:Blocks)

Build log:

-------------- Build: Debug in Hello World (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -fexceptions -g -std=c++11 -c "C:\Users\Matthew\Documents\Programming\C++\Code Blocks\Hello World\main.cpp" -o obj\Debug\main.o mingw32-g++.exe -o "bin\Debug\Hello World.exe" obj\Debug\main.o Process terminated with status 0 (0 minute(s), 3 second(s)) 0 error(s), 0 warning(s) (0 minute(s), 3 second(s))

Aucun commentaire:

Enregistrer un commentaire