相关疑难解决方法(0)

- 运营商对char*做了什么?

我是C的新手.我正在为C读取一个替换算法,我对这段代码中的-&+运算符有点困惑:

char *replace(char * src, const char * search, const char * replace) {
   char * buffer = malloc(4096);  //allocate 4096 bytes in memory to new string
   char * p; //substring of my search in the src string
   int i;

   p = strstr(src, search);
   if ( NULL == p ) return src; if // 'search' not found on 'src' return src
      i =  p - src; //index of my substring

   strncpy(buffer, src, i); //copy the substring …
Run Code Online (Sandbox Code Playgroud)

c string

0
推荐指数
1
解决办法
183
查看次数

标签 统计

c ×1

string ×1