1、getopt
putenv:把字串加到當前環境中;
3、程式可以通過 environ直接訪問到系統的環境變數
4、time_t time(time_t *tloc);返回從紀元開始至今的秒數;unix紀元的起點在2023年1月1日凌晨0點
struct tm *gmtime(const time_t timeval);輸入當前的秒數返回時間結構體。
struct tm *localtime(const time_t timeval);輸入當前的秒數返回當地時區時間結構體。
asctime 返回乙個字串,表示由tm結構timeptr所給出的時間和日期。
ctime 等效於 asctime(localtime(timeval))
size_t strftime把時間按照指定格式儲存到字串中
char* strptime 把字串讀取到時間結構體中
5、char *tmpnam(char *s)、構建乙個臨時檔名
file * tmpfile(void);構建乙個臨時檔案
6、使用者資訊:uid 使用者資訊的關鍵 型別uid_t
passwd結構體儲存使用者資訊 getpwuid(uid)
7、gethostname :獲得主機資訊
uname把主機資訊寫入name引數指向的結構
gethostid(void)獲得主機唯一識別符號
8、日誌 syslog
closelog
openlog
setlogmask
9、檢查標頭檔案math.h已經包含,原來雖然程式中已經包含math.h,但在鏈結時要鏈結到數學庫,加上-lm編譯選項即可,如下:
將 gcc whetstone.c -o whetstone 改為 gcc whetstone.c -lm -o whetstone即可 -lm表示使用 libm.so (或 libm.a) 這個函式庫的意思
第四章 程式設計
選擇語言的原則 最少的工作量原則 最少技巧性原則 最少錯誤原則 最少維護原則 減少記憶原則 總原則 先求正確後求快 先求清晰後求快 求快不忘保持程式正確性 保持程式整潔以求快 不要因效率而犧牲清晰 好程式標準 易於測試和除錯 易於維護 易於修改 設計簡單 高效率結構化程式設計主要包括兩方面 在編寫程...
程式設計珠璣第四章
正文裡面涉及到程式設計方法學的內容。不再細述 1 加及條件是0 l u n 1 2 這個函式可以寫成如下形式 int bs int a,int begin,int end,int v if e a end e v return e a return 1 再給一段測試 include include ...
第四章 Linux環境
程式引數 int main int argc char argv argc是程式引數的個數,argv是代表引數的字串陣列。以下對引數檢查 include include int main int argc,char argv else exit 0 帶引數執行 wuchao linux progra...