what does the - operator do with char *?

I new to C. I am reading a find-replace algorithm for C and I am a bit confused what the `-` & `+` operators do in this code: 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 value to buffer sprintf(buffer + i, "%s%s", replace, p + strlen(search)); // ??? return buffer; }

以上就是what does the - operator do with char *?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » CSS3 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准