SIZEOF
this operator is used to compute the size of its operand. it returns the size of a variable or the keyword that defines a type (int, char, etc) including types defined by the typedef keyword, expressions, and pointer type variables. this operator returns a number of type size_t.
int i; char c;
i = sizeof c;
* may not use parentheses with the sizeof operator when the argument is a
literal or a value
char tab[10];
i = sizeof tab;
* i is set to the value of 10, because this is the number of bytes occupied by the
entire tab array
char tab[10];
i = sizeof tab[1];
* i is set to the value of 1, because it points to the first element#include <stdio.h>
int main(int argc, char *argv[])
{
int integerValue = 16;
double doubleValue = 4.65;
printf("Size of int data type: %zu\n", sizeof(int));
printf("Size of double data type: %zu\n", sizeof(double));
printf("\nSize of integerValue variable: %zu\n", sizeof(integerValue));
printf("Size of doubleValue variable: %zu\n", sizeof(doubleValue));
return 0;
}AUTO-CALCULATING ARRAY SIZE:
AUTO-CALCULATING ARRAY SIZE: W/O THE NULL TERMINATOR
Last updated