第一个跑在linux上的c程序

来源:互联网 发布:显示时间软件 编辑:程序博客网 时间:2024/05/16 19:12

第一步:新建一个c_test.c文件;

hhhh@localhost ~$ vim c_test.c在其中输入以下内容://test c By MrBread 2017-01-20\#include<stdio.h>int main(){    printf("This is my first program on linux!\n" );    printf("I love programming!\n");    return 0;}:wq保存退出

第二步:编译c_test.c.

hhh@localhost ~$ gcc c_test.c    //默认输出a.out可执行文件

没有任何输出就是最好的输出!

此时使用ls指令可以看到当前目录下有一个a.out文件。

第三步:执行a.out文件

hhh@localhost ~$ ./a.out    //必须要在当前目录下

可以看到输出结果:

[root@markpain markpain]# ./a.outThis is my first program on linux!I love programming!

Success,第一个c程序跑在了linux上,撒花!


end
2017-01-20 MrBread

1 0
原创粉丝点击