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
相关文档:
1.apt-get update
更新本地apt-get的本地数据库,使其与服务器的pkglist文件同步。在升级以前一般都要执行本命令实现与服务器的一致。
2.apt-get check
验证本地系统的完整性。
3.apt-get dist-upgrade
类似于apt-get,但是将安装所有的基础软件包,并尽力升级一切软件包,并在需要是安装新软件包。
4.apt-get ......
1. 相关函数 & ......
1. 摘要
本文阐述
Linux 中的文件系统部分,源代码来自基于 IA32 的 2.4.20 内核。总体上说 Linux
下的文件系统主要可分为三大块:一是上层的文件系统的系统调用,二是虚拟文件系统 VFS(Virtual Filesystem
Switch),三是挂载到 VFS 中的各实际文件系统,例如 ext2,jffs 等。本文侧重于通过具体的代码分析来解释 Linux ......
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 ......