Here is my sample code
#include
void main()
{
int arr[]={1,2,3,4,5,6};
char *ptr,a;
a=\'c\';
ptr=&a;
int *ptr1,a1;
a1=4;
ptr1=&
the sizeof()
operator does not give you the number of elements in an array, it gives you the number of bytes a thing occupies in memory. Hence:
#include
int main()
{
char s[] = { 1, 2, 3, 4, 5, 0 };
int xs[] = { 1, 2, 3, 4, 5, 0 };
printf( "sizeof( s ) = %d\n", sizeof( s ) );
printf( "sizeof( xs ) = %d\n", sizeof( xs ) );
return 0;
}
sizeof( s ) = 6
sizeof( xs ) = 24