[root@localhost ~]# cd ch01
[root@localhost ch01]# ls
[root@localhost ch01]# vi listing1-1.c
#include
int main(void)
{
int dogs;
printf("How many dogs do you hava?\n");
scanf("%d",&dogs);
printf("So you hava %d dogs!\n",dogs);
return 0;
}
~
[root@localhost ch01]# gcc listing1-1.c(编译C,生成a.out)
[root@localhost ch01]# ls
a.out listing1-1.c listing1-1.o
[root@localhost ch01]# gcc -o listing listing1-1.c(编译C,指定源文件listing)
[root@localhost ch01]# ls
a.out listing listing1-1.c listing1-1.o
[root@localhost ch01]# ./listing(执行源文件)
How many dogs do you hava?
10
So you hava 10 dogs!
[root@localhost ch01]#
好久没有用C了,在linux编译C语言程序的感觉很好。舒服。
阅读(1701) | 评论(0) | 转发(0) |