随笔分类 - C库
摘要:#include <stdio.h> #include <time.h> struct tm *get_time(void) { time_t t; time(&t); t += 8*60*60; // 加时区 struct tm *tm = localtime(&t); tm->tm_year +
阅读全文
摘要:函数功能说明 #include <semaphore.h> int sem_init(sem_t *sem,int pshared,unsigned int value); // 初始化信号量(信号量地址,[0线程,>=1进程],初始值) int sem_destroy(sem_t *sem); /
阅读全文
摘要:目录操作函数 #include <sys/types.h> #include <dirent.h> #include <unistd.h> struct dirent { ino_t d_ino; // inode 编号 off_t d_off; // 到下一个目录项的偏移量 unsigned sh
阅读全文
摘要:类型转换 #include <stdlib.h> 数字 --> 字符串 ● itoa():将整型值转换为字符串。● ltoa():将长整型值转换为字符串。● ultoa():将无符号长整型值转换为字符串。● gcvt():将浮点型数转换为字符串,取四舍五入。● ecvt():将双精度浮点型值转换为字
阅读全文