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