for statement c code question
yes I'm using the book, teach yourself c in 21 days which I got off the net, and in showing to use nested for statements it uses this as an example:
1: /* Demonstrates nesting two for statements */
2:
3: #include <stdio.h>
4:
5: void draw_box( int, int);
6:
7: main()
8: {
9: draw_box( 8, 35 );
10:
11: return 0;
12: }
13:
14: void draw_box( int row, int column )
15: {
16: int col;
17: for ( ; row > 0; row--)
18: {
19: for (col = column; col > 0; col--)
20: printf("X");
21:
22: printf("\n");
23: }
24: }
I get how it works, but in the book it says that it doesn't work right if you don't substitute column for col in the nested for statements. I tried it in my compiler, dev-c++, and they were right. Would anyone be able to figure out why this might be? I'm very much stumped on this.....
|