返回首页   进站必读

2.5 gcc 的基本使用


2.5 gcc 的基本使用

2.5.1 编译一个c文件

下载hello.c,然后进入文件所在目录,输入gcc hello.c

#include <stdio.h>

int main(int argc, const char *argv[])
{
    printf("hello world!\n");

    return 0;
}

即可编译hello.c文件,生成的可执行文件是同级目录下的a.out,输入./a.out即可运行,在屏幕上打印出hello world!

$ls
hello.c
$gcc hello.c
$ls
hello.c a.out
$./a.out
hello world!