#include <stdio.h>
#include <stdlib.h>
Go to the source code of this file.
|
| main (int argc, char **argv) |
|
main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 29 of file sub.c.
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);