Friday, 9 February 2018

What is size_t?

  •  Unsigned integral type 
  • Alias of one of the fundamental unsigned integer types
  • It is a type able to represent the size of any object in bytes: 
  • size_t is the type returned by the sizeof operator and is widely used in the standard library to represent sizes and counts. 
  • It is used as a parameter in some functions: memchr, memcmp, memcpy, memmove, memset, strncat, strncmp, strncpy
  • It is used as the return type: strcspn, strlen, strspn and strxfrm to return sizes and lengths.
  • Size of size_t:  Depends on the compiler. If compiler is 4 byte (32 bit) then it is typedef for unsigned int. If compiler is 64 bit then it would be a typedef for unsigned long long. 
  • size_t is never negative. 

No comments:

Post a Comment