Go to diff to previous submission
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> char* buffer; char pattern[1024]; int blength; int plength; int i, n; int replace() { char* start; char* found; int offset; int j; offset = 0; start = buffer; do { if (found) { blength -= plength; start = found - plength; if (start < buffer) { start = buffer; } } }while(found); return 0; } int main(int argc, char *argv[]) { { for (i = 0; i < n; i++) { replace(); } } return 0; }
--- c4.s763.cteam116.bugs.c.0.main.c +++ c4.s778.cteam116.bugs.c.0.main.c @@ -30,5 +30,5 @@ if (found) { - memmove(found, found + plength, 2000020); + memmove(found, found + plength, blength + 1); blength -= plength; @@ -54,9 +54,9 @@ plength = strlen(pattern); gets(buffer); /* sezereme konec radky */ - blength = strlen(buffer); for (i = 0; i < n; i++) { fgets(buffer, 2000010, stdin); + blength = strlen(buffer); replace(); }