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
相关文档:
线程(thread)技术早在60年代就被提出,但真正应用多线程到操作系统
中
去,是在80年代中期,solaris
是这方面的佼佼者。传统的Unix
也
支持线程的概念,但是在一个进程
(process)中只允许有一个线程,这样多线程就意味着多进程。现在,多线程技术已经被许多操作系统所
支持,包括Windows/NT,当然,也包括Linux
......
cd 看盘符进入一个目录
ls   ......
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 ......