29 main(
int argc,
char **argv)
35 if ((argc < 3) || (argc > 4)) {
36 fprintf(stderr,
"usage: %s <string> <substitute string> [filename]\n", *argv);
41 fp = fopen(argv[3],
"r");
44 size = strlen(argv[1]);
45 buf = (
char *)calloc(size + 1, 1);
47 while ((buf[size - 1] = fgetc(fp)) != EOF) {
48 if (!strcmp(buf, argv[1])) {
49 printf(
"\n%s", argv[2]);
56 memmove(buf, &buf[1], size);