2

I'm new to programming and a bit confused with arrays, what seems to be wrong in this code, as eclipse output console is saying ** Build of configuration Debug for project Project **

Internal Builder is used for build ** gcc -O0 -g3 -Wall -c -fmessage-length=0 -omain.o ..\main.c gcc -oProject.exe main.o C:...\Documents\eclipse\mingw\bin..\lib\gcc\mingw32\3.4.5........\mingw32\bin\ld.exe: cannot open output file Project.exe: Permission denied collect2: ld returned 1 exit status Build error occurred, build is stopped Time consumed: 472 ms.

I will really appreciate your help...

int main()
{
    int box[2][2], rows, cols, x = 1;

    for (rows=0; rows < 2; rows++)
    {

        for (cols=0; cols < 2; cols++)
        {
            box[rows][cols] = x++;
            printf("%d", box[rows][cols]);
        }

    }
    fflush(stdout);
    getch();
    return 0;
}
4

1 回答 1

1

x++ 是后增量,因此使用 x 的值然后递增,因此 box[0][0] 为 1

于 2013-06-11T15:23:45.830 回答