[c]linux下构建lib库

2016-11-24 写技术

来来来,新技能,linux下构建lib库的步骤: 1、准备库函数源文件; my_add.c int add(int a, int b){ printf("Here is my_add.c\n"); return a+b; } my_sub.c int sub(int a, int b){ printf("Here is my_sub.c \n"); return a-b; } 2、生成目标文件; gcc -c my_add.c...

阅读全文>>

标签: C linux

评论(0) 浏览(1413)

[c]mosquitto编码实现websockets协议

2016-10-20 写技术

mosquitto虽然本身是支持websockets协议的,但却依懒libwebsockets库,而libwebsockets库是基于poll的,所以如果想把mosquitto改为epoll模式很容易,却不能兼容websockets了。 为了解决这个纠结的问题,这几天把websockets协议用C语言重新实现了一遍,然后将mosquitto中调用libwebsockets的部分用自己的代码取代,今天终于实现了websockets下的mqtt通讯功能。 首先一些websockets的结构放在websockets.h中: typedef struct _WebSo...

阅读全文>>

标签: C linux

评论(0) 浏览(1729)

[c]uthash

2016-10-14 写技术

An example about uthash #include "uthash.h" #include <stdlib.h> /* malloc */ #include <stdio.h> /* printf */ typedef struct _user_t { int id; char name[25]; UT_hash_handle hh; } USER_T,*PUSER_T; void main() { int i; PUSER_T user, users=NULL; ...

阅读全文>>

标签: C

评论(0) 浏览(1346)

[c]strtok_r,strtok_s, _strtok_s_l, wcstok_s, _wcstok_s_l, _mbstok_s, _mbstok_s_l

2016-10-11 写技术

On the first call to strtok_s the function skips leading delimiters and returns a pointer to the first token in strToken, terminating the token with a null character. More tokens can be broken out of the remainder of strToken by a series of calls to strtok_s. Each call to strtok_s modifies strToken ...

阅读全文>>

标签: C

评论(0) 浏览(1552)

[c]构造合法身份证

2016-6-27 写技术

#include <stdio.h> #define LEN 18 void main(){ char id[LEN] = {0}; int weight[] = {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2}; int validate[] = {1,0,'x'-'0',9,8,7,6,5,4,3,2,1}; int i=0; int sum = 0; printf("Input your id\n"); ...

阅读全文>>

标签: C

评论(0) 浏览(1330)

[C]Source Insight常用的快捷键

2016-3-16 写技术

Ctrl+= :Jump to definition Alt+/ :Look up reference F3 : search backward F4 : search forward F5: go to Line F7 :Look up symbols F8 :Look up local symbols F9 :Ident left F10 :Ident right Alt+, :Jump backword Alt+. : Jump forward Shift+F3 : search the word under cusor backward Shift+F4 : s...

阅读全文>>

标签: C

评论(0) 浏览(1388)

[C]比最简单的程序更简单的C程序

2016-2-2 写技术

在C语言里面,你以为"Hello world"真的就是最简单的程序了么? Anycle来告诉你,还有比“Hello world”更简单的C语言程序,我们直接上代码: void main(){} 哈哈,看到没,简单吧,没有头文件,没有任何输入,没有任何输出,没有任何动作。 gcc 编译后只有8K左右。

阅读全文>>

标签: C

评论(0) 浏览(1296)

[C]gettimeofday()

2016-2-2 写技术

#include <stdio.h> #include <sys/time.h> #include <string.h> void test_gettimeofday(){ struct timeval tv; struct timezone tz; gettimeofday(&tv, &tz); printf("tv.tv_sec = %d , tv.tv_usec = %d \n", tv.tv_sec, tv.tv_usec); prin...

阅读全文>>

标签: C

评论(0) 浏览(1303)

[C]strtok()

2016-2-2 写技术

#include <stdio.h> #include <string.h> void main(){ char str[] = "i am nicholas"; char *ret = NULL; ret = strtok(str, " "); printf("ret:%s\n", ret); while(ret = strtok(NULL, " ")){ printf("ret:%s\n", ret); } }

阅读全文>>

标签: C

评论(0) 浏览(1247)

[C]Why function getenv() return a minus value

2016-2-2 写技术

In the case include no stdlib.h file, the function getenv() return a minus value. #include <stdio.h> #include <stdlib.h> void main(){ int rc; char *env = NULL; env = getenv("LIB"); printf("&env = %d \n", env); if(env){ printf("config home:%d\n", env); } ...

阅读全文>>

标签: C

评论(0) 浏览(1358)

Powered by anycle 湘ICP备15001973号-1