我是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)