Fork me on GitHub

一 操作步骤

1.生成可执行程序

cd xxx            # 先进入源程序所在的目录

gcc hello.cpp        # 一次性编译,windows系统生成a.exe文件,Linux系统生成a.out文件

gcc hello.cpp -o hello.exe  # -o表示输出

gcc hello.cpp -o ./tmp/hello.exe  # -o后面也可以跟其他目录,注意tmp目录必须存在,否则gcc会抛出异常

 

2.运行可执行文件

hello.exe      # 运行hello.exe文件,如果是Linux系统,是./hello.out文件,如果电脑有McAfee杀软,要关闭

 

二 源码解析

#include <stdio.h>

int main()
{
        printf("hello world \n\r");

        return 0;
}

 

三 运行结果

 

posted on 2023-06-07 15:02  虚生  阅读(248)  评论(0编辑  收藏  举报