[c]linux下构建lib库
来来来,新技能,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]mosquitto编码实现websockets协议
mosquitto虽然本身是支持websockets协议的,但却依懒libwebsockets库,而libwebsockets库是基于poll的,所以如果想把mosquitto改为epoll模式很容易,却不能兼容websockets了。 为了解决这个纠结的问题,这几天把websockets协议用C语言重新实现了一遍,然后将mosquitto中调用libwebsockets的部分用自己的代码取代,今天终于实现了websockets下的mqtt通讯功能。 首先一些websockets的结构放在websockets.h中: typedef struct _WebSo...[c]uthash
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
[c]strtok_r,strtok_s, _strtok_s_l, wcstok_s, _wcstok_s_l, _mbstok_s, _mbstok_s_l
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
[c]构造合法身份证
#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
[C]Source Insight常用的快捷键
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
[C]比最简单的程序更简单的C程序
在C语言里面,你以为"Hello world"真的就是最简单的程序了么? Anycle来告诉你,还有比“Hello world”更简单的C语言程序,我们直接上代码: void main(){} 哈哈,看到没,简单吧,没有头文件,没有任何输入,没有任何输出,没有任何动作。 gcc 编译后只有8K左右。标签: C
[C]gettimeofday()
#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
[C]strtok()
#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
[C]Why function getenv() return a minus value
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
日历
最新微语
- 有的时候,会站在分叉路口,不知道向左还是右
2023-12-26 15:34
- 繁花乱开,鸟雀逐风。心自宁静,纷扰不闻。
2023-03-14 09:56
- 对于不可控的事,我们保持乐观,对于可控的事情,我们保持谨慎。
2023-02-09 11:03
- 小时候,
暑假意味着无忧无虑地玩很长一段时间,
节假意味着好吃好喝还有很多长期不见的小朋友来玩...
长大后,
这是女儿第一个暑假,
一个半月...
2022-07-11 08:54
- Watching the autumn leaves falling as you grow older together
2018-10-25 09:45
分类
最新评论
- Goonog
i get it now :) - 萧
@Fluzak:The web host... - Fluzak
Nice blog here! Also... - Albertarive
In my opinion you co... - ChesterHep
What does it plan? - ChesterHep
No, opposite. - mojoheadz
Everything is OK!... - Josephmaigh
I just want to say t... - ChesterHep
What good topic - AnthonyBub
Certainly, never it ...