回调函数及c调用shell命令

网友投稿 329 2022-08-23

回调函数及c调用shell命令

#include #include #include #include void fun1(){ char a[10] = {0}; char payload[10]= {'1','2','3','4','5','6'}; memcpy(a,payload,10); char path[20] = {0}; sprintf(path,"%s",a); printf("path = %s\n",path); char cmd[255] = {0}; sprintf(cmd,"mkdir -p %s > /dev/null 2>&1 | echo ${?}",path); FILE *fp = NULL; fp = popen(cmd,"r"); fclose(fp); }void (*mediacallback)(char type, char status, char *path, void *tempdata, int arg) = NULL;void api_setTakeCallBack(void(*callback)(char type, char status, char *path, void *tempdata, int arg)) { puts("---------api_setTakeCallBack--------------"); mediacallback = callback;}int api_takePic(char type, char status, char *_pic_path, char *_name) { puts("----------api_takePic------------");}void MediaRegister(char type, char st, char *path, void *tempdata, int arg) { puts("---------MediaRegister-----------");}void fun(){ static int i = 0; i++; printf("--------i = %d---------\n",i);}void fun2(){ int i; printf("----------i = %d--------\n",i);}int main(){ // api_setTakeCallBack(MediaRegister); // api_takePic(0, 0, 0, 0); // mediacallback(1, 0, 0, 0, 0); // fun();// sleep(1); // fun(); // fun2(); unsigned short int a = 0; while (1) { /* code */ a++; printf("---------a = %d---------\n",a); }; return 0;}

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Python中经典排序方法(python实现各种排序)
下一篇:【LeetCode】求根节点到叶节点数字之和
相关文章

 发表评论

暂时没有评论,来抢沙发吧~