Lecture 01¶
Linux¶
C¶
- Designed by Dennis Ritchie 丹尼斯·里奇
- First appeared: 1972
- TIOBE Index - The TIOBE Programming Community index is an indicator of the popularity of programming languages.
hello.c
/* File: hello.c
* -------------
* This program prints a welcome message to the user.
*/
#include <stdio.h> // for printf
int main(int argc, char * argc[]) {
printf("Hello, World!\n");
return 0;
}
工作流程¶
- ssh
- vim / emacs
- gcc
- gdb
args.c
/* args.c
* ------
* This program prints out information about its received
* command-line arguments.
*/
#include <stdio.h>
int main(int argc, char* argv[]) {
printf("This program received %d argument(s)\n", argc);
for (int i = 0; i < argc; i ++ ) {
printf("Argument %d: %s\n", i, argv[i]);
}
return 0;
}
printf¶
- print format
- console output
- placeholder 格式化占位符
%s
- string%d
- integer, decimal%f
- double, float%p
- pointer
bool¶
推荐阅读¶
- The Strange Birth and Long Life of Unix, Warren Toomey, IEEE Spectrum, 28 Nov 2011
- “A damn stupid thing to do” - the origins of C, Arstechnica, 12/9/2020
- The history of C, Dennis Ritchie
- Dennis Ritchie: the giant whose shoulders we stand on, Arstechnica, SEAN GALLAGHER, 10/14/2011
- K&R, ch1, cn
- K&R, ch1, en
- CSAPP, ch1