Home >Backend Development >C#.Net Tutorial >What is size in c language
size is an operator in C language used to obtain the size of a data type, returning the number of bytes of unsigned int type. Its functions are: allocating memory; data processing; data alignment.
size in C language
size is an operator used in C language to obtain the size of a data type. It returns the number of bytes occupied by the specified data type, as a value of type unsigned int.
Usage:
The size operator is followed by the data type to obtain the size, for example:
<code class="c">int a; printf("int 类型的大小为:%lu 字节\n", sizeof(int));</code>
Function: ## The
#size operator is mainly used for the following purposes:Example:
The following example demonstrates how to use the size operator:<code class="c">#include <stdio.h> int main() { printf("char 类型的大小为:%lu 字节\n", sizeof(char)); printf("int 类型的大小为:%lu 字节\n", sizeof(int)); printf("float 类型的大小为:%lu 字节\n", sizeof(float)); printf("double 类型的大小为:%lu 字节\n", sizeof(double)); return 0; }</code>
Output:
<code>char 类型的大小为:1 字节 int 类型的大小为:4 字节 float 类型的大小为:4 字节 double 类型的大小为:8 字节</code>
The above is the detailed content of What is size in c language. For more information, please follow other related articles on the PHP Chinese website!