Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux 程式設計 >> Linux 程式設計

Linux C 編程:who 命令的第一版實作與 Eclipse 開發流程

第一版 who 命令直接開啟 UTMP_FILE,逐筆讀取 struct utmp,再輸出使用者、終端機、時間與主機。它沒有做過多型態判斷,因此更像是最小可行版本。

while (read(utmpfd, &current_record, reclen) == reclen) {
    show_info(&current_record);
}

在 Windows 下,這類程式通常無法直接編譯,因為 utmp.h、UTMP_FILE 等是 Unix-like 系統特有。若使用 Eclipse 在 Linux 開發,不必手動 gcc,只要 Build 後執行,就能在控制台看到結果。Eclipse 的價值主要在語法檢查、專案管理與執行輸出整合。

Copyright © Linux教程網 All Rights Reserved