Arrays in C
printf("Enter a no.: ");
printf("Size: %d " , sizeof(x));
void printsize(int x)
printf("Size: %ld \n", sizeof(x));
Enter a no: 4
This is my simple code.when i run it, i get two different sizes for array x.Y is it so?
When I pass x as a param to another function,it returns me a different size!
Please reply asap.
Assuming you're using a C99 compatible compiler I wouldn't be surprised that you got different values for x in main() and x in your function. You're not comparing the same things. In the function you're looking at the sizeof the pointer, not the sizeof the array as in main.