
C函数-OPQRST
jichunlai
学着生活
展开
-
使用alarm和setjmp实现超时控制
#include #include #include #include #include #include #define JMP_VALUE 12345 static jmp_buf test_jmp_env; static void test_alarm(int n) { printf("alarm signal:%d\r\n", n); longjmp(test_原创 2013-04-03 15:02:38 · 1818 阅读 · 0 评论 -
lrzsz
lrzsz原创 2013-09-03 10:53:06 · 452 阅读 · 0 评论 -
C函数signal实例
信号是Linux编程中非常重要的部分,本文将详细介绍信号机制的基本概念、Linux对信号机制的大致实现方法、如何使用信号,以及有关信号的几个系统调用。 信号机制是进程之间相互传递消息的一种方法,信号全称为软中断信号,也有人称作软中断。从它的命名可以看出,它的实质和使用很象中断。所以,信号可以说是进程控制的一部分。 一、信号的基本概念转载 2012-09-06 07:23:48 · 1457 阅读 · 0 评论 -
获取程序执行的“挂钟时间”,“用户时间”,“系统时间”
简单的程序可以通过命令实现 # time ./test real 0m2.033s user 0m2.032s sys 0m0.000s 不方便用time命令的可以使用系统函数实现 #include //用户获取用户时间,系统时间 static struct tms tms_start; static struct tms tms_end; //用于获取挂钟时间 stati原创 2013-06-24 15:35:57 · 1057 阅读 · 0 评论 -
pread pwrite
pread pwrite原创 2013-05-10 15:16:44 · 1610 阅读 · 0 评论 -
linux判断文件/目录类型
#include #include #include int main(int argc, char *argv[]) { if(argc != 2) return 1; struct stat buf; memset(&buf, 0, sizeof(struct stat)); lstat(argv[1], &buf); //lstat原创 2013-05-08 16:51:17 · 1775 阅读 · 0 评论 -
C函数printf
1. 原样输出字符串: printf("%s", str); 2. 输出指定长度的字符串, 超长时不截断, 不足时右对齐: printf("%Ns", str); --N 为指定长度的10进制数值 3. 输出指定长度的字符串, 超长时不截断, 不足时左对齐: printf("%-Ns", str); --N 为指定长度的10进制数值 4. 输出指定长度的字原创 2012-09-06 07:23:46 · 1428 阅读 · 0 评论 -
C函数sscanf
sscanf() - 从一个字符串中读进与指定格式相符的数据. 函数原型: Int sscanf( string str, string fmt, mixed var1, mixed var2 ... ); int scanf( const char *format [,argument]... ); 头文件: #i nclude 说明: sscanf与s转载 2012-09-06 07:23:51 · 1394 阅读 · 0 评论 -
C Time相关函数和结构
//1, time_t 转 struct tm struct tm *localtime( const time_t *timer ); //2,struct tm 转 time_t time_t mktime( struct tm *timeptr ); struct tm { int tm_sec; /*秒,正常范围0-59, 但允许至61*转载 2012-09-06 07:23:54 · 1421 阅读 · 0 评论 -
pipe实例
#include #include #include #include #include #include #include #include int pipe_execv(const char *psCmd, char *const argv[], int (*fn_line_callback)(char *)) { int fd[原创 2012-12-26 18:19:27 · 1340 阅读 · 0 评论 -
使用setrlimit控制进程使用系统内存
#include #include #include #include #include int main(void) { int nMemoryLimit = 1024 * 1024 * 5;//5M struct rlimit memoryL; getrlimit(RLIMIT_AS, &memoryL); printf("before set mem:%lu,%lu\原创 2013-04-03 14:44:09 · 2951 阅读 · 0 评论 -
gettimeofday()函数的使用方法:
一.gettimeofday()函数的使用方法: 1.简介: 在C语言中可以使用函数gettimeofday()函数来得到时间。它的精度可以达到微妙 2.函数原型: #include int gettimeofday(struct timeval*tv,struct timezone *tz ) 3.说明: gettimeofday()会把目前的时间用tv 结构体转载 2013-04-28 16:42:27 · 1879 阅读 · 0 评论 -
pipe实例
#include #include #include #include #include int fds[2]; int main(void){ if(-1 == pipe(fds)){ printf("pipe fail\r\n"); exit(0); } pid_t pid = fork();原创 2012-08-31 18:11:50 · 1667 阅读 · 0 评论 -
shm共享内存使用示例
#include #include #include #include #include #include #include #include typedef struct { int nId; char sValue[1024]; }MemTest; MemTest *ptTest = NULL; int InitMem() { int SYS_MPU原创 2013-04-02 11:14:15 · 1943 阅读 · 0 评论 -
name pipe & socket使用select-没那么简单
name pipe & socket使用select-没那么简单原创 2014-03-07 21:42:45 · 697 阅读 · 0 评论