for (a=0; a<10; a++)
{
printf ("%d",matrix1[a]);
}
1 2 3 4
for (a=0; a<10; a++);
{
printf ("%d",matrix1[a]);
}
For the 1st code i get 10 zeros which are the matrix contents.
For the 2ond code I dont get an error but a "4006960"
In what is the for function transformed if you put a ";" in the end?
--------------------------------------------------------------------------------------------
My blog [http://georgesblogprogramming.blogspot.com]. Personal notes and experiences in the learning of C
In the first case, it becomes an empty loop. The same applies for the second, but the block below it is executed just once.
In the first case, the block below the for gets executed 10 times. In the second case, the semicolon makes the loop empty. So it runs ten times without doing nothing, and then executes the code below.