使用教材
《“笨办法” 学C语言(Learn C The Hard Way)》
https://www.jianshu.com/p/b0631208a794
Makefile
CFLAGS=-Wall -g
all: clean ex1 ex3
clean:
rm -f ex1 ex3
ex3.c
#include <stdio.h>
int main()
{
int age;
int height = 72;
printf("I am %d years old.\n",age);
printf("I am %d inches tall.\n",height);
return 0;
}
$
anno@anno-m:~/Desktop$ make all
rm -f ex1 ex3
cc ex1.c -o ex1
cc ex3.c -o ex3
anno@anno-m:~/Desktop$ ls
ex1 ex1.c ex3 ex3.c ex3.c~ Makefile Makefile~
anno@anno-m:~/Desktop$ ./ex3
I am 0 years old.
I am 72 inches tall.
- 查看 printf 的 help
anno@anno-m:~$ man 3 printf
printf %d %s
https://en.cppreference.com/w/c/io/fprintf
Escape sequences
https://en.cppreference.com/w/c/language/escape
网友评论