易截截图软件、单文件、免安装、纯绿色、仅160KB

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


相关文档:

Linux操作系统下的多线程编程详细解析

线程(thread)技术早在60年代就被提出,但真正应用多线程到操作系统

去,是在80年代中期,solaris
是这方面的佼佼者。传统的Unix

支持线程的概念,但是在一个进程
(process)中只允许有一个线程,这样多线程就意味着多进程。现在,多线程技术已经被许多操作系统所
支持,包括Windows/NT,当然,也包括Linux ......

linux常用命令

cd                                         看盘符进入一个目录
ls       ......

Linux 线程同步 条件变量

1. 相关函数                                                & ......

Linux性能监控工具的介绍文章

基于进程的命令方式查看:
`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 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号