原创 Linux --sigaction舉例(改變信號默認操作)
環境 -- ubuntu64位 部分內核宏及函數對照/*signal number*/ #define SIGHUP 1 #define SIGINT 2 #define SIGQUIT
原创 Linux -- 信號量編程接口封裝及如何實現互斥與同步
下面的例子清晰地了說明如何使用一個信號量實現臨界資源互斥,兩個信號量實現互斥同步。 信號量接口封裝 sem.h #ifndef _SEM_H #define _SEM_H int get_sem(int k
原创 Linux --共享內存單向讀寫舉例(非同步->同步機制)
用到的函數: Liunux – ftok函數 部分內核的宏: #ifndef _ASM_GENERIC_ERRNO_BASE_H #define _ASM_GENERIC_ERRNO_BASE_H #define EPERM
原创 Liunux -- ftok函數
翻譯自Ubuntu 19版本下的Linux Programmer's Manual 函數名:ftok – 將一個路徑名和一個對象標識符轉換爲System V IPC鍵值。 概要:#include <sys/types.h>
原创 Linux -- tcp單向文件傳輸例程
tcp_send_file.c #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> #incl
原创 Linux -- 無名管道pipe單向讀寫演示實例
#include <sys/types.h> #include <sys/wait.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <s
原创 Linux -- 有名管道mkfifo單向讀寫實例
fifo_write.c #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd
原创 Linux -- fflush函數
翻譯自Ubuntu 19版本下的Linux Programmer's Manual 函數名:fflush - 刷新一個流 概要: #include <stdio.h> int fflush(FILE
原创 Linux -- dup, dup2, dup3
翻譯自Ubuntu 19版本下的Linux Programmer's Manual 函數名:dup, dup2, dup3 - 複製一個文件描述符 概要: #include <unistd.h> int dup(in
原创 Linux -- ls -l 命令的函數實現
函數: Linux – stat, fstat, lstat, fstatat函數 Linux – asctime, ctime, gmtime, localtime, mktime, asctime_r, ctime
原创 Linux -- stat, fstat, lstat, fstatat函數
函數名:stat, fstat, lstat, fstatat - 獲取文件的狀態 概要: #include <sys/types.h> #include <sys/stat.h> #include <u
原创 Linux -- asctime, ctime, gmtime, localtime, mktime, asctime_r, ctime_r, gmtime_r, localtime_r函數
函數名:asctime, ctime, gmtime, localtime, mktime, asctime_r, ctime_r, gmtime_r, localtime_r - 轉換日期和時間成分解時間(修正時
原创 動態庫(.so)的製作
擴展: linux gcc命令 描述: a. 動態庫也叫共享庫 b. 動態庫把對一些庫函數的鏈接載入推遲到程序運行的時期(runtime)。 c. 可以實現進程之間的資源共享。 d. 將一些程序升級變得簡單。 e.
原创 c語言中的邏輯值
說明: 邏輯值有兩種:“真”和“假”。 非0爲真,否則爲假。 c語言沒有提供邏輯值給用戶使用,c++提供了以True表示真,False表示假。 條件判斷、關係運算符、邏輯表達式的結果都是邏輯值。 由於c語言的靈活特性,以1代表
原创 c運算符優先級和結合性
各運算符分類 運算符的優先級和結合性: 說明: a.大多數運算符的結合性都是自左向右,唯獨單目運算符、條件運算符和賦值運算符是自右向左的。 b.同一優先級的運算符優先級別相同,運算次序由結合方向決定。例