I'm studying C and I came across the code below. The printed results are always the same for all the printf calls.
What does [x,y] mean?
A memory address or something else?
printf("%d ", array[0,0]);
printf("%d ", array[1,0]);
printf("%d ", array[2,0]);
The comma operator in c returns the second argument. So 0,0, 1,0, and 2,0 all evaluate to 0, so its no wonder that all the printf statements print the same result. If you want to refer to an element in a two-dimensional array by its indexes, you need to use two sets of square bracket. E.g., array[1][0].
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With