#4 为什么 C/C++ 不可替代
编程语言 Clang 2022-10-31英文原文:https://levelup.gitconnected.com/why-modern-alternative-languages-never-replace-c-c-cbf0afc5f1dc
中文翻译:https://mp.weixin.qq.com/s/tr69w96gOO7ia81ttilgVA
总结一下:
- C/C 是优秀的系统级编程语言,无数基础设施是用 C/C 开发的
- C/C++ 可以完全控制机器,开发者拥有最大的灵活性
- C/C++ 性能非常好
- C/C++ 学术友好,简单,高效,直接(没有封装得很抽象)
- 所有操作系统提供 C API,其他语言也都提供了和 C 交互的方式
#3 c const
Clang 2021-10-06#2 阮一峰的 C 语言教程学习
Clang 阮一峰 2021-09-07目录
- 1. 简介
历史,标准,Hello World - 2. 基本语法
基本语法,printf
格式化 - 3. 变量
- 4. 运算符
- 5. 流程控制
- 6. 数据类型
- 整型的不同进制表示
limits.h
中的极限值- 关于布尔型,
int
,_Bool
(C99,int
别名),bool
/true
/false
(stdbool.h
) - 字面量后缀 (
l
,ll
,u
,f
) - 类型转换
- 可移植类型 (
stdint.h
)
- 7. 指针
- 8. 函数
- 9. 数组
- 10. 字符串
- 11. 内存管理
- 12. struct 结构
- 13. typedef 命令
- 14. Union 结构
- 15. Enum 结构
- 16. 预处理器
- 17. I/O 函数
- 18. 文件操作
- 19. 变量说明符
- 20. 多文件项目
- 21. 命令行环境
- 22. 多字节字符
- 23. 标准库
- 23.1.
assert.h
- 23.2.
ctype.h
- 23.3.
errno.h
- 23.4.
float.h
- 23.5.
inttypes.h
- 23.6.
iso646.h
- 23.7.
limits.h
- 23.8.
locale.h
- 23.9.
math.h
- 23.10.
signal.h
- 23.11.
stdint.h
- 23.12.
stdlib.h
- 23.13.
stdio.h
- 23.14.
string.h
- 23.15.
time.h
- 23.16.
wchar.h
- 23.17.
wctype.h
- 23.1.
关键字
// 数据类型 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
signed
,unsigned
- 浮点数:
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