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
相关文档:
3.2.1 Linux 内存绑定在局部存储器的实现总体步骤
总体步骤:
l 采用方案三,在在原来分析的基础上,以及已知Linux系统内存的初始化的情况,对内核代码进行修改,主要包括确定新区的范围,建立新区,重新对分配内存的分配机制进行设置。
l &n ......
以下是配置引导进入图形模式的etc/inittab文件的部分内容:
#Default runlevel.The runlevels used by RHS are:
# 0-halt(Do NOT set initdefault to this)
# 1 -Single user mode
# 2-Multiuser,without NFS(The same as 3,if you do not have networking)
# 3-Full multiuser mode
# 4-unu ......
1. 相关函数 & ......
基于进程的命令方式查看:
`ps -o pcpu,pmem,nlwp -p $PID`
#(pmem = % mem usage and nlwp is number of threads)
其中pcpu定义是:cpu utilization of the process in “##.#” format. It is the CPU time used divided by the time the process has been running (cputime/realtime ratio), expressed as a ......
1. 摘要
本文阐述
Linux 中的文件系统部分,源代码来自基于 IA32 的 2.4.20 内核。总体上说 Linux
下的文件系统主要可分为三大块:一是上层的文件系统的系统调用,二是虚拟文件系统 VFS(Virtual Filesystem
Switch),三是挂载到 VFS 中的各实际文件系统,例如 ext2,jffs 等。本文侧重于通过具体的代码分析来解释 Linux ......