Use sizeof operator to determine the memory requirements of arrays. - C Data Type

C examples for Data Type:sizeof

Introduction

The following code calculates how many elements are contained in an array by dividing the array size by the size of the array data type.

Demo Code

#include <stdio.h> 
int main()//from w  w w .j a va 2s  .co  m
{ 
   int array[10]; 
   printf("\nSize of array: %d bytes\n", sizeof(array)); 
   printf("Number of elements in array "); 
   printf("%d\n", sizeof(array) / sizeof(int)); 
}

Result


Related Tutorials