C language example-Calculate the byte size of int, float, double and char (sizeof operator)

  • sizeof is a kind of unary operator of C language, such as other operators of C language ++,-etc. It is not a function.
#include <stdio.h> 
int main()
{
    
    
/*sizeof 操作符以字节形式给出了其操作数的存储大小。*/
printf("int的字节大小%d\t\n",sizeof(int));
printf("float的字节大小%d\t\n",sizeof(float));
printf("double的字节大小%d\t\n",sizeof(double));
printf("char的字节大小%d\t\n",sizeof(char));
return 0;
}

Guess you like

Origin blog.csdn.net/qq_41017444/article/details/112425701