栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

Linux环境下的C语言编程

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Linux环境下的C语言编程

Linux环境下编程笔记

目录
  • 1.shell脚本的hello wored
  • 2.C语言脚本的hello wored
  • 3.C语言调用shell命令及脚本

1.shell脚本的hello wored

新建一个shell脚本touch hello.sh


通过shell指令执行脚本:
使用chomd 775开放权限或者使用bash直接运行

#!/bin/bash
echo "hello world my shell"
2.C语言脚本的hello wored

1.新建一个c文件touch hello.c
2.编译:gcc hello.c回车,然后会生成一个名叫a.out 的执行文件
生成指定名字的.out文件gcc hello.c -o hello.out
3.运行:./a.out回车

#include
#include//延时函数引用头文件
int main(void)
{
  printf("hello wordn");
  sleep(3);//延时函数秒单位
   printf("hello wordn");
  return 0;
}
3.C语言调用shell命令及脚本

Linux中C语言执行shell脚本的方法: https://blog.csdn.net/u010299133/article/details/85637263

#include
#include//system函数驱动shell命令
#include//延时函数引用头文件
int main(void)
{
  printf("hello wordn");
  sleep(3);//延时函数秒单位
   printf("hello wordn");
  system("bash ./hello2.sh");//执行shell脚本
  return 0;
}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/989732.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号