Linux下创建shell、C小程序介绍


1.创建一个shell脚本文件

gedit  hello_shell.sh  ##创建文件

2.###在文件内添加一下内容

#!/bin/bash

for  ((i=0;i<10;i++));do

  echo   "hello shell"

done

exit 0

3.为文件添加可执行权限

chmod 755 hello_shell.sh

4.执行脚本

./hello_shell.sh

 

###创建一个C语言程序"hello world"

1.gedit  hello_world.c

2.##添加一下内容

#include  <stdio.h>

int  main(void)

{

  printf("hello world!\n");

  return 0;

}

3.保存后使用gcc生成可执行文件

gcc  -o  hello_world  hello_world.c

gcc生成的二进制文件,默认具有可执行权限,不需要修改

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM