码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • linux centos运行C语言程序


    1.安装gcc。 yum install gcc

    [root@linux ~]# yum install gcc
    已加载插件:fastestmirror, langpacks
    Repository updates is listed more than once in the configuration
    Repository extras is listed more than once in the configuration
    Loading mirror speeds from cached hostfile
     * base: mirrors.aliyun.com
    base                                                                                                                                                                                | 3.6 kB  00:00:00     
    docker-ce-stable                                                                                                                                                                    | 3.5 kB  00:00:00     
    epel                                                                                                                                                                                | 4.7 kB  00:00:00     
    extras                                                                                                                                                                              | 2.9 kB  00:00:00     
    mysql-connectors-community                                                                                                                                                          | 2.6 kB  00:00:00     
    mysql-tools-community                                                                                                                                                               | 2.6 kB  00:00:00     
    mysql57-community                                                                                                                                                                   | 2.6 kB  00:00:00     
    os                                                                                                                                                                                  | 3.6 kB  00:00:00     
    updates                                                                                                                                                                             | 2.9 kB  00:00:00     
    (1/3): epel/7/x86_64/updateinfo                                                                                                                                                     | 1.0 MB  00:00:00     
    (2/3): epel/7/x86_64/primary_db                                                                                                                                                     | 7.0 MB  00:00:00     
    (3/3): updates/7/x86_64/primary_db                                                                                                                                                  |  23 MB  00:00:01     
    软件包 gcc-4.8.5-44.el7.x86_64 已安装并且是最新版本
    无须任何处理
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21

    2.创建C语言文件
    下述以创建hello.c输出hellowolrd为例
    vim hello.c
    在hello.c加入C语言代码

    #include
    int main()
    {
    printf("Hello World ! ");
    return 0 ; 
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    保存退出 !wq

    [root@linux ctest]# ls
    hello.c 
    
    • 1
    • 2

    3.编译 C 语言代码,并生成可执行文件
    在hello.c当前目录执行 gcc -o hellotest hello.c 就会生成名为hellotest的可执行文件

    [root@linux ctest]# gcc -o hellotest hello.c
    [root@linux ctest]# ls
    hello.c  hellotest
    
    
    • 1
    • 2
    • 3
    • 4

    4.执行可执行文件
    在当前目录执行./hellotest

    [root@linux ctest]# ./hellotest
    Hello World ! 
    
    • 1
    • 2
  • 相关阅读:
    硬件【10】运放-1-理想运放与虚断虚短的来源
    自然语言处理实战项目20-一看就懂的BERT模型介绍,指导大家对BERT下游任务改造的实际应用
    资源画像,看得见的容器资源优化助手
    别跟客户扯细节
    <sa8650>sa8650开发板-之-刷机教程(flashing)
    基于Bert迁移学习点击未知弹框
    基于ssm操作系统课程网站
    自用纯C语言实现任务调度(可用于STM32、C51等单片机)
    2022年Redis最新面试题第2篇 - Redis数据结构
    Pause Giant AI Experiments: An Open Letter(暂停大型人工智能实验: 一封公开信)
  • 原文地址:https://blog.csdn.net/wasane/article/details/133612608
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号