Linux下C语言实现字符串子串替换
由于LINUX
C没有对字符串子串替换功能,所以我自己写了一个str_replace函数,实现了字符串替换.
请大家参考.
/*
* FUNCTION : str_replace
*
ABSTRACT : replace child string in a string.
*
PARAMETER :
*
char* str
the string that be replace
*
char* str_src source string
*
char* str_des destination string
*
RETURN :
*
0 OK
*
-1 FALSE
* CREATE : 2006-01-05
ZHANG.JINCUN
* NOTE
:
*/
int str_replace(char* str,char* str_src, char*
str_des){
char *ptr=NULL;
char buff[256];
char buff2[256];
int i = 0;
if(str !=
NULL){
strcpy(buff2, str);
}else{
printf("str_replace err!\n");
return -1;
}
memset(buff,
0x00, sizeof(buff));
while((ptr = strstr( buff2,
str_src)) !=0){
if(ptr-buff2 != 0) memcpy(&buff[i], buff2, ptr - buff2);
memcpy(&buff[i + ptr - buff2], str_des, strlen(str_des));
i += ptr - bu
相关文档:
总览
用iptables -ADC 来指定链的规
则
,-A添加 -D删除 -C 修改
iptables - [RI] chain rule num rule-specification[option]
用iptables - RI 通过规则的顺序指定
iptables -D chain rule num[option]
删除指定规则
iptables -[LFZ] [chain][option]
用iptables -LFZ 链名 [选项]
iptables -[NX] chain
用 -NX ......
1.自启动:
在/etc/inittab文件中设置:
# Default runlevel. (Do not set to 0 or 6)
id:5:initdefault:
2.字符终端模式下启动x-windows:
startx ......
两种方法:
自启动程序方法1:
在etc/rc.local在里面加入/home/robin/code/autoruntest > /dev/null &(其中autoruntest 测试程序名称,下同)。即可自启动
注:/etc/rc.local -> /etc/rc.d/rc.local
自启动程序方法2:
创建linux服务,步骤如下:
1) &n ......
Curl是Linux下一个很强大的http命令行工具,其功能十分强大。
1) 读取网页
$ curl http://www.linuxidc.com
2) 保存网页
$ curl http://www.linuxidc.com > page.html
$ curl -o page.html http://www.linuxidc.com
3) 使用的proxy服务器及其端口: -x
$ curl -x 123.45.67.89:1080 -o page.html http://www.linu ......