
linux C 高编 系统编程
linbounconstraint
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Linux 环境下/etc/profile和/etc/profile.d 的区别
http://c.biancheng.net/view/1023.htmlLinux 环境下/etc/profile和/etc/profile.d 的区别/etc/profile 文件当一个用户登录Linux系统或使用su -命令切换到另一个用户时,也就是Login shell 启动时,首先要确保执行的启动脚本就是 /etc/profile 。只有Login shell 启动时才会运行 /etc/profile 这个脚本,而Non-login shell 不会调用这个脚本。一些重要的变量就是在这个原创 2021-07-06 16:43:41 · 241 阅读 · 0 评论 -
将字符串转化为16进制数
将字符串转换成16进制数比如一组32个字符的,如4c8c6827f05dbc64b1c43e7e343d9adc4c8c6827f05dbc64b1c43e7e343d9adc,字符串。字符串的内容为0~f,如果以字符的形式写到flash里面,占用32个字节大小转成十六进制的话,占用一半大小,即16个字节。代码:#include <stdio.h>#include <...原创 2019-11-08 11:46:07 · 17400 阅读 · 0 评论 -
popen,argc,argv, cprintf, snprintf,strcmp,write,read,strspn,strcspn,
(转)popen简单说一下popen()函数函数定义#include FILE * popen(const char *command , const char *type );int pclose(FILE *stream);函数说明 popen()函数通过创建一个管道,调用fork()产生一个子进程,执行一个shell以运行原创 2015-11-12 14:12:55 · 632 阅读 · 0 评论 -
epoll使用详解(精髓)
epoll - I/O event notification facility在linux的网络编程中,很长的时间都在使用select来做事件触发。在linux新的内核中,有了一种替换它的机制,就是epoll。相比于select,epoll最大的好处在于它不会随着监听fd数目的增长而降低效率。因为在内核中的select实现中,它是采用轮询来处理的,轮询的fd数目越多,自然耗时越多。并且转载 2014-09-19 16:06:12 · 463 阅读 · 0 评论 -
(转)cin、cin.get()、cin.getline()、getline()、gets()等函数的用法
cin、cin.get()、cin.getline()、getline()、gets()等函数的用法链接:点击打开链接1、cin>> 用法1:最基本,也是最常用的用法,输入一个数字:#include iostream> using namespace std; main () { int a,b; cin原创 2015-09-16 15:32:44 · 431 阅读 · 0 评论 -
获取某值的具体某位
获取某值的具体某位函数:unsigned char get_bit(unsigned char temp, int bit) 获取某值的具体某位。 参数:temp为传入的值,bit是要获取temp的值具体某一位的值 返回值:函数返回 传入参数temp的第bit位的值。 #include #include原创 2015-09-01 16:47:51 · 827 阅读 · 0 评论 -
(转)OSI七层模型详解
源地址:点击打开链接 作者:小鹏_加油 OSI 七层模型通过七个层次化的结构模型使不同的系统不同的网络之间实现可靠的通讯,因此其最主要的功能就是帮助不同类型的主机实现数据传输 。完成中继功能的节点通常称为中继系统。在OSI七层模型中,处于不同层的中继系统具有不同的名称。 一个设备工作在哪一层,关键看它工作时利用哪一层原创 2015-09-15 17:26:58 · 1103 阅读 · 0 评论 -
目录操作 递归打印目录 DIR drent
/*打印当前目录的文件名*//*./a.out string查找当前目录下,所有文件,文件内容有string,打印出文件名*/#include #include #include #include #include #define N 1024int main(int argc, char **argv){ DIR *dp; struct dirent *item原创 2014-11-12 19:03:32 · 1124 阅读 · 1 评论 -
myserver myclient
myserver myclient原创 2014-11-23 12:00:56 · 654 阅读 · 0 评论 -
简单 time I/O 写入日志文件 get_time
#if 0#ifndef _TM_DEFINEDstruct tm {int tm_sec; /* 秒 – 取值区间为[0,59] */int tm_min; /* 分 - 取值区间为[0,59] */int tm_hour; /* 时 - 取值区间为[0,23] */int tm_mday; /* 一个月中的日期 - 取值区间为[1,31] */int tm_mon; /* 月份原创 2014-08-23 18:57:39 · 570 阅读 · 0 评论 -
select 监听
/* * reads input from pipes p1, p2 * using select() for multiplexing * * tty1:cat > ./p1 * tty2:cat > ./p2 * tty3: ./select */ #include #include #include #include #include int main(v原创 2014-08-27 20:41:10 · 1283 阅读 · 0 评论 -
mmap 用mmap实现cp命令
/*mmap 可以把磁盘文件的一部分直接映射到内存,这样文件中的位置直接就有对应的内存地址,对文件的读写可以直接用指针来做而不需要read/write 函数。#include void *mmap(void *addr, size_t len, int prot, int flag, int filedes, off_t off);int munmap(void *addr原创 2014-09-10 16:10:57 · 988 阅读 · 0 评论 -
sscanf()的用法和例子
%[ ] 的用法:%[ ]表示要读入一个字符集合, 如果[ 后面第一个字符是”^”,则表示反意思。 [ ]内的字符串可以是1或更多字符组成。空字符集(%[])是违反规定的,可 导致不可预知的结果。%[^]也是违反规定的。 %[a-z] 读取在 a-z 之间的字符串,如果不在此之前则停止转载 2014-11-05 19:16:52 · 487 阅读 · 0 评论 -
修改目录里面的.jpg结尾的文件改为.png (pid system fgets fork)
/*将改目录里面的.jpg结尾的文件改为.png 调用mv实现不使用opendir*/原创 2014-09-12 18:57:50 · 755 阅读 · 0 评论 -
C语言调用sqlite3 学生管理系统
s'q'li'te#include #include #include #include #define DB_NAME "zb.db"#define TRUE 1#define FALSE 0sqlite3 *pdb = NULL;char *Errmsg = NULL;//创建数据库 zb.dbint open_db(){原创 2014-11-24 08:02:17 · 2634 阅读 · 1 评论 -
编译 libstring.so lib库 libstring.c libstring.h makefile
libstring.c#include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h> /* for isDigit, really should be in oal_strconv.c */#include <sys/stat.h> ...原创 2019-07-04 14:49:44 · 302 阅读 · 0 评论 -
socket网络编程 poll的简单用法
void* task_sync_app_as_client_thread(){ my_printf(LOG_MODE_LEVEL_3, " %s(%d) linbo......\n",__FUNCTION__,__LINE__); int i=0; struct pollfd fds[3]; json_object *boot_json =NULL; boot_json = js...原创 2019-06-13 13:56:17 · 2166 阅读 · 0 评论 -
linux获取uplink的wifi的channel信息
iwlist wlan0 channel | grep 'Frequency' | awk '{print $5}' | sed 's/[()]//g'wlan0是5G的接口root@OpenWrt:~# iwlist wlan0 channel wlan0 32 channels in total; available frequencies : Channe...原创 2019-02-21 11:12:12 · 1310 阅读 · 0 评论 -
读写文件
读写文件 FILE *fpin = NULL; FILE *fpout = NULL; char str1[512] = {0}; char str2[512] = {0}; system("iptables-save >/tmp/.currentipt"); fpin = fopen(IPTABLES_CURRENT...原创 2018-03-23 16:36:55 · 151 阅读 · 0 评论 -
查找文件里里是否存在字符串
//Check the chain in the file /tmp/.ipt, whether it has already existed. // return 1 (already existed) return 0 (not find)#include #include int check_ipt_existed_chain(char *find_str){原创 2018-01-26 15:16:12 · 395 阅读 · 0 评论 -
C 1.pass_list_check 2.某个文件中是否存在特定的字符串 3.replace
pass_list checkchar *pass_list[] = { "/images/", "/cgi/cgi_wan_multiple.js", "/chglang.cgi", "/global.js"#if 0 "/loginzz.htm", "/wireless_calibration.htm", "/bottom_pan原创 2016-08-17 19:09:09 · 400 阅读 · 0 评论 -
SecureCRT 配色方案
SecureCRT 配色方案一、配色后的效果图二、设置背景颜色 1、选项(Options)==》会话选项(Sessions options)==》终端(Terminal)==》仿真(Emulation) 2、在 终端(T) 下拉列表中选择Linux,勾选 ANSI颜色(A) 3、选项(Options)==》全局选项(Global options)==》终端(Terminal)==》外观(App原创 2016-08-31 13:51:52 · 783 阅读 · 0 评论 -
(转)Linux系统下proc目录详解
Linux系统下proc目录详解 链接深入理解linux系统下proc文件系统内容 链接*******************************************************************************1,、proc — 一个虚拟文件系统 /proc 文件系统是一种内核和内核模块用来向进程 (process)原创 2015-11-13 14:59:40 · 449 阅读 · 0 评论 -
用户使用键盘循环输入字符,select监听终端,将用户输入的字符输出到终端上
/* *用户使用键盘循环输入字符,select监听终端,将用户输入的字符输出到终端上 *如果用户指定时间内没有做输入,提示超时,用户输入‘q’退出。 */#include #include #include #include #include #include int main(void){ fd_set rfds, inset; struct timeval tv;原创 2014-11-12 15:16:56 · 964 阅读 · 0 评论 -
MS(三) socket server client 网络编程
一些参数说明/******************************************************* -----------------------------------------------sockaddr_in结构体struct sockaddr_in{ short sin_family;/*Addressfamily一般原创 2015-09-17 17:19:09 · 867 阅读 · 0 评论 -
server client (开源中国)
/*server.c ====================================================================*/ #include // for sockaddr_in#include // for socket#include // for socket#include // for prin原创 2014-11-22 17:45:48 · 463 阅读 · 0 评论 -
stat 函数
在中定义的stat结构体内容如下:[cpp] view plaincopyprint?struct stat { dev_t st_dev; /* ID of device containing file */ ino_t st_ino; /* inode number */转载 2014-08-23 09:24:36 · 585 阅读 · 0 评论 -
popen
#include FILE *popen(const char *command, const char *type); int pclose(FILE *stream);原创 2014-09-12 19:06:54 · 569 阅读 · 0 评论 -
哲学家吃饭
#include #include #include struct chops{ int id; pthread_mutex_t *left, *right;};void *philosopher(void * arg){ struct chops * p = arg; while(1){ pthread_mutex_lock(p->原创 2014-09-13 17:32:03 · 511 阅读 · 0 评论 -
ntohs, ntohl, htons,htonl的比较和详解
文章出处:http://www.diybl.com/course/3_program/c++/cppsl/200899/141291.htmlntohs =net to host short int 16位htons=host to net short int 16位ntohs =net to host long int 32位htonl=host to net long in转载 2014-09-17 11:47:31 · 561 阅读 · 0 评论 -
fork mmap 共享映射区
#include #include pid_t fork(void);fork 调用失败则返回-1原创 2014-09-11 15:59:02 · 1183 阅读 · 0 评论 -
pipe 管道
管道是一种最基本的 IPC 机制,由pipe 函数创建:#include int pipe(int filedes[2]);调用pipe 函数时在内核中开辟一块缓冲区(称为管道)用于通信,它有一个读端一个写端,然后通过filedes 参数传出给用户程序两个文件描述符,filedes[0]指向管道的读端,filedes[1]指向管道的写端(很好记,就像0 是标准输原创 2014-09-11 16:54:56 · 664 阅读 · 0 评论 -
环境变量 getnv environ
一、什么是环境变量?Linux是一个多用户的操作系统。多用户意味着每个用户登录系统后,都有自己专用的运行环境。而这个环境是由一组变量所定义,这组变量被称为环境变量。用户可以对自己的环境变量进行修改以达到对环境的要求。二、定制环境变量环境变量是和Shell紧密相关的,它是通过Shell命令来设置的。环境变量又可以被所有当前用户所运行的程序所使用。对于bash来说,可以通过变量名来访问转载 2014-08-28 11:14:20 · 684 阅读 · 0 评论 -
lseek dup dup2 read
/*off_t lseek(int fd, off_t offset, int whence);*参数 whence SEEK_SET 头SEEK_CUR 当前位置SEEK_END 尾*参数 offset 偏移量(矢量,可以是正值也可以是负值,负值向前偏移)参数offset 和whence 的含义和fseek 函数完全相同。只不过第一个参数换成了文件描述符。和fseek原创 2014-09-10 16:09:31 · 499 阅读 · 0 评论 -
sigaction 读取和修改与指定信号相关联的处理动作 捕捉信号ctr+c
/*sigcation:可以读取和修改与指定信号相关联的处理动作SYNOPSIS #include int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);sigaction()会依参数signum指定的信号编原创 2014-09-09 16:17:09 · 744 阅读 · 0 评论 -
解释的很好的。堆,栈。程序的内存分布。 bss data rodata text heap stack。
一个程序一般分为3段:text段,data段,bss段text段:就是放程序代码的,编译时确定,只读,data段:存放在编译阶段(而非运行时)就能确定的数据,可读可写就是通常所说的静态存储区,赋了初值的全局变量和静态变量存放在这个区域,常量也存放在这个区域bss段:定义而没有赋初值的全局变量和静态变量,放在这个区域 这个够不够清楚呢?堆栈就是栈的简称。堆和栈的区别一、预备知识—转载 2014-08-25 14:17:09 · 824 阅读 · 0 评论 -
bss、data和rodata区别与联系
http://blog.youkuaiyun.com/laiqun_ai/article/details/8528366转载 2014-08-22 19:08:48 · 2727 阅读 · 0 评论 -
select函数(二)
//输入a转变为大写A#include #include #include #include #include #include #define N 1024int main(void){ fd_set rfds, tmp; int retval; int maxfd; struct timeval tv;// char buf[N]; char ch, ch_re原创 2014-08-22 19:24:46 · 749 阅读 · 0 评论 -
selsect 函数(一)
/* *用户使用键盘循环输入字符,select监听终端,将用户输入的字符输出到终端上 *如果用户指定时间内没有做输入,提示超时,用户输入‘q’退出。 */#include #include #include #include #include #include int main(void){ fd_set rfds, inset; struct timeval tv;原创 2014-08-22 19:21:32 · 1363 阅读 · 0 评论 -
my-dir-ls
#include #include #include #include #include #include #include int fun();int main(int argc, char *argv[]){ int num; num = fun(); printf("total:%d\n", num); return 0;}int fun(void)原创 2014-11-12 20:52:35 · 645 阅读 · 0 评论