1 #include <stdio.h>
2
3 main()
4 {
5 printf("Hello world.\n");
6 }
yannzi@ubuntu:~/桌面/_7$ cc hello.cyannzi@ubuntu:~/桌面/_7$ ./a.out Hello world.yannzi@ubuntu:~/桌面/_7$ echo $?13yannzi@ubuntu:~/桌面/_7$ cc -std=c99 hello.chello.c:4: 警告: 返回类型默认为‘int’yannzi@ubuntu:~/桌面/_7$ ./a.out Hello world.yannzi@ubuntu:~/桌面/_7$ echo $?0 1 #include "apue.h"
2
3 static void my_exit1(void);
4 static void my_exit2(void);
5
6 int main()
7 {
8 if (atexit(my_exit2) != 0)
9 printf("can't register my_exit2");
10 if (atexit(my_exit1) != 0)
11 printf("can't register my_exit1");
12 if (atexit(my_exit1) != 0)
13 printf("can't register my_exit1");
14 printf("main is done\n");
15 return 0;
16 }
17
18 static void
19 my_exit1()
20 {
21 printf("first exit handler\n");
22 }
23
24 static void
25 my_exit2()
26 {
27 printf("second exit handler\n");
28 }
yannzi@ubuntu:~/桌面/_7$ gcc -o stop_to_process_program stop_to_process_program.c yannzi@ubuntu:~/桌面/_7$ ./stop_to_process_program main is donefirst exit handlerfirst exit handlersecond exit handler 1 #include "apue.h"
2
3 int
4 main(int argc, char *argv[])
5 {
6 int i;
7
8 for (i = 0; i < argc; i++) //echo all command-line args
9 printf("argv[%d]: %s\n", i, argv
);
10 exit(0);
11 }
yannzi@ubuntu:~/桌面/_7$ gcc -o echo_all_command_line_args_7_3 echo_all_command_
line_args_7_3.c
yannzi@ubuntu:~/桌面/_7$ ./echo_all_command_line_args_7_3
argv[0]: ./echo_all_command_line_args_7_3
yannzi@ubuntu:~/桌面/_7$ ./echo_all_command_line_args_7_3 arg1 TEST foo
argv[0]: ./echo_all_command_line_args_7_3
argv[1]: arg1
argv[2]: TEST
argv[3]: foo
共享库
cc -static //阻止gcc使用共享库
setjmp和longjmp函数
文章评论(0条评论)
登录后参与讨论