+ 1
sizeof funtion with a loop in c!
why the result of using sizeof function in the second example is differing from the first example: int c[5]={1,2,3,4,5}; // Example 1 : for(int i=0;i<5;i++) { printf("c[%d] = %d \n",i,c[i]); } printf("\n\n\n\n"); //Example 2 : for(int i=0;i<sizeof(c);i++) { printf("c[%d] = %d\n",i,c[i]); }
12 Respostas
+ 4
As a size note, you can use:
sizeof(c) / sizeof(int)
to get the number of elements in the int array c.
+ 4
sizeof operator returns array size in bytes. To find length of array :
https://www.freecodecamp.org/news/how-to-find-the-size-of-an-array-in-c-with-the-sizeof-operator/amp/
+ 3
Jayakrishna đźđł thank you đ
+ 2
Mirielle thank you for this explanation, I appreciate it đ
+ 2
You're welcome..
+ 1
Lochard thank you đ