- https://wangdoc.com/clang/
- GitHub, https://github.com/wangdoc/clang-tutorial
目录
关键字
// 数据类型 12
short int long double float
char struct union enum typedef
signed unsigned
// 变量 6
auto register extern const volatile
static
// 函数 2
void return
// 控制语句 11
if else for continue while do
switch case default goto break
// 其他 1
sizeof
数据类型
- 整数:
short
, int
, long
, long long
- 浮点数:
float
, double
- 字符:
char
, char *
#include <stdio.h>
int main(){
printf("size of int: %2ld\n", sizeof(int));
printf("size of short: %2ld\n", sizeof(short));
printf("size of long: %2ld\n", sizeof(long));
printf("size of long long: %2ld\n", sizeof(long long));
printf("size of float: %2ld\n", sizeof(float));
printf("size of double: %2ld\n", sizeof(double));
printf("size of long double: %2ld\n", sizeof(long double));
printf("size of char: %2ld\n", sizeof(char));
}
$ uname -a
Linux dell 5.11.0-34-generic #36-Ubuntu SMP Thu Aug 26 19:22:09 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
$ gcc --version
gcc (Ubuntu 10.3.0-1ubuntu1) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ gcc /tmp/test.c -o /tmp/test && /tmp/test
size of int: 4
size of short: 2
size of long: 8
size of long long: 8
size of float: 4
size of double: 8
size of long double: 16
size of char: 1