1 / 9

Unix 指令 4- 文字編輯與程式撰寫

Unix 指令 4- 文字編輯與程式撰寫. vi 編輯器. 開 ( 新 ) 檔案 vi filename 分為三種模式 一般模式 編輯模式 指令模式. vi 編輯器. 指令模式. :set :set nu 顯示行號 :set nonu 取消行號顯示 :set ic :e! 還原至檔案編修前的狀態 :r <filename> 讀入檔案內容,並加到游標行的 後面 :q 退出不儲存 :q! 強制退出不儲存. 練習. 將「線上使用者清單」寫入 test.txt 新檔 利用 vi 編輯 test.txt 文字檔 將自己的學號插入於第 3 行

ena
Download Presentation

Unix 指令 4- 文字編輯與程式撰寫

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Unix指令4-文字編輯與程式撰寫

  2. vi編輯器 • 開(新)檔案 vi filename • 分為三種模式 • 一般模式 • 編輯模式 • 指令模式

  3. vi編輯器

  4. 指令模式 • :set • :set nu 顯示行號 • :set nonu取消行號顯示 • :set ic • :e! 還原至檔案編修前的狀態 • :r <filename>讀入檔案內容,並加到游標行的後面 • :q 退出不儲存 • :q! 強制退出不儲存

  5. 練習 • 將「線上使用者清單」寫入test.txt新檔 • 利用vi編輯test.txt文字檔 • 將自己的學號插入於第3行 • 將第4、5行資料刪除 • 將第3行學號改成自己的信箱 • 將第3行學號複製到最後一行 • 存檔離開 • 查看test.txt內容

  6. pico編輯器 • 開(新)檔案 • pico filename • 常用指令說明 • ctrl +g (get help) • pico的輔助說明檔----對pico的用法有不懂之處,就可查此說明檔。 • ctrl +x (exit) • 離開pico----當你編輯好後,按此指令就可離開pico編輯畫面。 • 當按了 ^x 後,會先出現下列這一行: Save modified buuffer (ANSWERING  " No " WILL DESTROY CHANGES ) ?問你是否要存檔,如果要則按y,反之按n。

  7. 程式撰寫 • 使用C語言程式架構 • 開啟新的test.c檔 • vitest.c • 程式架構 • #include<stdio.h> //納入標準IO函式庫 • main(){ //主程式 • printf(“hello\n”); //印出hello字串 • }

  8. 程式執行 • 執行程式分成兩個步驟: • 編譯程式─產生執行檔 • 執行程式─輸出結果 • 編譯程式:使用gcc編譯器 • gcctest.c(沒給執行檔檔名,預設產成a.out) • gcctest.c -o abc(產生abc執行檔) • 執行程式 • a.out • abc

  9. 程式撰寫 • C語言程式語法可使用引數 • #include<stdio.h> • main(intargc, char *argv[]){ inti; for(inti= 0; i< argc, i++) printf(“%s\n”, argv[i]); • } • 執行程式 • a.out hello world

More Related