I am new to C and currently learning arrays. I have this code:
#include <stdio.h>
int main()
{
int available[6];
for(int o=1; o<=3; o++){
available[o]=20;
printf("%d\n",&available[o]);
}
return 0;
}
Which is supposed to output (in my understanding):
20
20
20
Now the problem is that it outputs:
2293300
2293304
2293308
Am i missing a crucial part and did some silly mistake?. Any help will be appreciated.
printf("%d\n",&available[o]);
Here you are printing the address, because &
gives the address of the following value, change it to:
printf("%d\n",available[o]);
to print the value inside the array.