随笔分类 - 自己写的函数
摘要:// 使用popen代替system函数 int my_system(const char * cmd) { FILE * fp; int res;if (cmd == NULL) { printf("my_system cmd is NULL!\n"); return -1; } if ((fp
阅读全文
摘要:1 #include <stdbool.h> 2 #include <sys/types.h> 3 #include <sys/stat.h> 4 #include <unistd.h> 5 6 bool file_exist(const char *path) // 返回值:0 - 不存在, 1
阅读全文
摘要:#include <stdio.h> typedef int (*function_pointer)(int a, int b); int func(int a, int b, function_pointer test) { test(a, b); } int add(int a, int b)
阅读全文
摘要:log.c: #define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> #include <time.h> #include <unistd.h> #inclu
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 7 #define SJXC_LOG_DEBUG(level, format, arg...) SJXC_log_msg_print(level, __FILE__, __func__, __LINE__, format, ##arg) 8 9...
阅读全文
摘要:1 #include <stdio.h> 2 #include <string.h> 3 4 main() 5 { 6 char *str = "123 abc 456 def 7"; 7 char buf[32]; 8 int j = 0, i = 0; 9 10 memset(buf, '\0', sizeof(buf)); 11 for (i = 0; i < strlen(str); ++
阅读全文
摘要:#define NONE "\033[m"#define RED "\033[0;32;31m"#define LIGHT_RED "\033[1;31m"#define GREEN "\033[0;32;32m"#define LIGHT_GREEN "\033[1;32m"#define BLU
阅读全文
摘要:printf函数: 运行结果:test_num : 123 error函数: 运行结果:Error: main failure 函数: 运行结果: string :aint :1char :b 函数: 运行结果: tmp : 1tmp : 2tmp : 3tmp : 4 和上边的函数进行对比: 运行
阅读全文
摘要:1 #include 2 #include 3 4 int main(void) 5 { 6 FILE *fp; 7 char line[512], tmp[256]; 8 char *receive_flowrate, *transmit_flowrate, *net_card_name; 9 long total_count_flowr...
阅读全文
摘要:#include #include #include #include #include #include int main (int argc, const char * argv[]) { struct ifaddrs * ifAddrStruct=NULL; void * tmpAddrPtr=NULL; getifaddrs(&ifAd...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 // #include 8 #include 9 // #include 10 11 #define IF_NAME "eth0" 12 13 int main(void) 14 { 15 struct ifr...
阅读全文
摘要:#include int main(void) { int result[100]; int num, i = 0, j; printf("Please enter a number :\n"); scanf("%d", &num); while(num) { result[i++] = num % 2; num =...
阅读全文

浙公网安备 33010602011771号