Hi all,I am facing problem with the memcpy function while copying
for (i = 0; i <= ((128*1024)-len); i++) {
if (memcmp(buf + i, search_data,len) == 0) {
memcpy(buf + i, &replace_data, len);
}
}
Upto some value the data is copying then the memcmp function fails.I dnt know why…?
buf is char pointer and search_data and replace_data char array of len-32.
here the len is 8.
if you do the correction i told you, it works as expected. by the way, you could use the strstr() function of the C standard library that does almost the exact same thing:
p = strstr(buf, search_data);
memcpy(p, replace_data, strlen(replace_data));
Hi ,I tried with strstr it’s giving the Segfault.
If possible can you post me the program for copying blocks of data into memory location.Thanks in advance…!!