Respected SIR There is an array having 10 integers. Integers occupy 4 bytes. So when sizeof(a) is applied, result is 40 as expected, but when sizeof(a+1) is calculated, it gives result 4.
basically when u write (a+1) it means a[1] so sizeof(a+1) is equal to sizeof(a[1]) so naturally sizeof(a[1]) is 4bytes... hope u got ur answer
no dear basically an integer occupies 2 bytes in memory and if u wrote size of(a+1) where a is an integer which occupies 2 bytes and 1 is also an integer which also occupies 2 bytes and the total memory becomes 4 bytes 2 bytes of each integer...
do you help me in making a program. that's the program qs. below Take 5 country names in an array (string) and perform sorting in alphabetical order.country starts with A comes 1st ano on and on
Just try printf("size of int : %d\n", sizeof(int)) in TurboC (freeware 2.01 originally for MS DOS) and in borland C++ freeware for windows (bcc32) - you will find that for turboC you get 2 and for bcc32 you get 4. So sizeof(int) is implementation dependent. And (a + 1) does not refer to a[ 1 ] -- *(a + 1) refers to a[ 1 ]
Iam sorrry if im wrong because i saw this type of notation in the book called ANSI C by BYRON S GOTTFRIED.