Facebook Page Twitter Page LinkedIn Page
× C Standard Library


The C <stddef.h> size_t type is an alias of one of the fundamental unsigned integer type. This is a type able to represent the size of an object in bytes. It is the type returned by the sizeof operator and is commonly used in the standard library to represent sizes and counts.

In the <stddef.h> header file, it is defined as follows:

typedef /*implementation-defined*/ size_t;              

Example:

The below example shows the usage of size_t type.

#include <stdio.h>
#include <stddef.h>
 
int main (){
  //creating an array of size 10
  //and type size_t
  int size = 10;
  size_t arr[size];
    
  //populating the elements of array
  for(size_t i = 0; i < size; i++)
    arr[i] = i;

  //displaying the elements of array
  printf("arr contains: \n");
  for(size_t i = 0; i < size; i++)
    printf("%d ", arr[i]);
 
  return 0;
}

The output of the above code will be:

arr contains: 
0 1 2 3 4 5 6 7 8 9 

❮ C <stddef.h> Library