linux 時間日期

所有的unix,包括linux,以1970年1月1日午夜(0點)為起點。linux系統中所有的時間都以從那時起經過的秒數來衡量。時間類型:time_t#include <time.h>time_t time(time_t *tloc);  struct tm* gmtime(const time_t *timeval);代碼:time_t tim=time(NULL);struct tm * tm_ptr=gmtime(&tim);printf("week:

linux 臨時檔案

臨時檔案的使用需要注意:檔案不可同時被多個任務編輯char *tmpnam(char *s) 建立與當前已存在的所有檔案不同名的檔案問題:其他程式也能open and edit與tmpnam返回的檔案名稱同名的檔案註:檔案名稱is assumed to至少L_tmpnam(通常是20)characters long該函數至多能被調用TMP_MAX(至少幾千)次in a single program. FILE *tmpfile(void);

linux 使用者資訊

除了init程式外,所有的linux程式都是由其他程式或使用者啟動的UID是使用者身份的關鍵,類型uid_t#include <sys/types.h>#include <unistd.h>uid_t getuid(void);  啟動程式的使用者的UIDchar* getlogin(void); 與目前使用者關聯的登陸名 /etc/passwd/etc/shadow #include <sys/types.h>#include

linux getopt函數詳細分析

標準庫函數:getopt   標頭檔 #include <unistd.h>int getopt(int argc, char * const argv[],const char *optstring);解釋:take the argc and argv as passed to main function (argc和argv參數與int main(int argc,char * argv[])相同)and an options specifier string that

linux curses 彩色顯示

以下內容摘自 beginning linux programming 一書編譯時間加上 -lncurses選項#include <unistd.h>#include <stdlib.h>#include <stdio.h>#include <curses.h>int main(){int i;initscr();if(!has_colors()){endwin();fprintf(stderr,"error - no color support

linux下庫的使用

《精通unix下c語言-編程與項目實踐》學習筆記1.庫的分類   庫可分為靜態庫和動態庫兩種。     

linux壓縮和解壓縮命令大全

linux壓縮和解壓縮命令大全        .tar  解包:tar zxvf FileName.tar  打包:tar czvf FileName.tar DirName  ---------------------------------------------  .gz  解壓1:gunzip FileName.gz  解壓2:gzip -d FileName.gz  壓縮:gzip FileName  .tar.gz 和 .tgz  解壓:tar zxvf

高手給菜鳥學習Linux的10個建議

隨著Linux應用的擴充許多朋友開始接觸Linux,根據學習Windows的經驗往往有一些茫然的感覺:不知從何處開始學起。這裡介紹學習Linux的一些建議。  一、從基礎開始:常常有些朋友在Linux論壇問一些問題,不過,其中大多數的問題都是很基礎的。例如:為什麼我使用一個命令的時候,系統告訴我找不到該目錄,我要如何限制使用者的許可權等問題,這些問題其實都不是很難的,只要瞭解了 Linux 的基礎之後,應該就可以很輕易的解決掉這方面的問題。而有些朋友們常常一接觸Linux

linux 終端 讀取每個字元

以下內容來自 beginning linux programming一書第5章 終端#include <stdio.h>#include <stdlib.h>#include <termios.h>char *menu[] = {"a - add new record","d - delete record","q - quit",NULL,};int getchoice(char *greet,char *choices[],FILE *in,

linux下使用errno的幾個需要主要的地方

以下內容轉自http://hi.baidu.com/tekuba/item/b247ce5a9a8653c8d2e10c51 errno - number of last errorerrno 記錄linux系統的最後一次錯誤碼。代碼是一個int型的值,在errno.h中定義 注意引用他的方法,看下面一例:if (somecall() == -1){  printf("somecall() failed\n");if(errno == ...){ ...

linux 檔案管理相關函數介紹

fileno函數:檔案流(FILE*)->檔案描述符#include <stdio.h>int main(void){ FILE * fp;  //檔案流int fd;   //檔案描述符fp=fopen("/home/yaoyin/bin/test/1.c","r");fd=fileno(fp);   printf("fd=%d\n",fd);fclose(fp);return 0;}結果: fd=3(0 stdin 1 stdout 2 stderr

linux 使用termios結構的密碼程式

以下內容摘自 beginning linux programming#include <termios.h>#include <stdio.h>#include <stdlib.h>#define PASSWORD_LEN 8int main(){struct termios its,newits;char password[PASSWORD_LEN+1];tcgetattr(fileno(stdin),&its);newits =

linux 檔案地區鎖

F_GETLK, F_SETLK and F_SETLKW are used to acquire,  release,  and  test       for  the existence of record locks (also known as file-segment or file-       region locks).  The third argument, lock, is a pointer to  a  structure       that has at

linux 建立鎖檔案

#include <unistd.h>#include <stdlib.h>#include <stdio.h>#include <fcntl.h>#include <errno.h>int main(){int file_desc;int save_errno;file_desc = open("/tmp/LCK.test",O_RDWR|O_CREAT|O_EXCL,0444);if(file_desc ==

linux 與終端對話

以下內容來自  beginning linux programming/dev/tty 指向當前終端或當前的登陸會話,可將它當作檔案一樣操作代碼:menu1.c#include <stdio.h>#include <stdlib.h>char *menu[] = {"a - add new record","d - delete record","q - quit",NULL,};int getchoice(char *greet,char

linux 對終端進行讀寫

以下代碼摘自linux程式設計  英文名:beginning linux programming#include <stdio.h>#include <stdlib.h>char *menu[] = {"a - add new record","d - delete record","q - quit",NULL,};int getchoice(char *greet,char *choices[]);int main(){int choice =

linux curses 管理多視窗

以下內容來自 linux beginning programming #include <unistd.h>#include <stdlib.h>#include <curses.h>int main(){WINDOW *new_window_ptr;WINDOW *popup_window_ptr;int x_loop;int y_loop;char a_letter =

linux控制台的常用操作

移動:方向鍵上、下:移動一行空格:向後一屏b(小寫):向前一屏先輸入數字,比如3,然後按上述的鍵,可相應上下移動3行,翻滾3屏。u 向前半屏d 向後半屏 搜尋:/abc 搜尋含有abc的字串在搜尋到結果後,按n鍵向後繼續搜尋,N鍵則是向前。 跳轉:g 跳到整篇文章的起始G 跳到整篇文章的末尾p  先輸入50,再按p,跳到文章的一半位置處(p是percent百分比的縮寫) 編輯命令行:HOME 移動游標到行首END 移動游標到行尾control+U刪除整行

linux 下 curses庫 安裝 和使用

以下內容轉自http://blog.163.com/lghct@126/blog/static/64551808201024101630455/ curses庫是用來開發簡單圖形介面程式一個庫(也許它的功能不止這些,但是目前我只知道這一個!:)。Ubuntu下安裝方法:sudo apt-get install libncurses5-devcurses的基本用法如下:1. 包含標頭檔:curses.h2. 編譯時間應加上連結語句-lcurses,如:gcc temp.c -o temp

linux 檢測標準輸出是否被重新導向

代碼: 1.c#include <unistd.h>#include <stdio.h>#include <stdlib.h>int main(){ if(!isatty(fileno(stdout))){fprintf(stderr,"You are not a terminal\n");exit(1);}exit(0);}gcc 1.c -o t./t    ./t > file  輸出You are not a

總頁數: 3662 1 .... 679 680 681 682 683 .... 3662 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.