Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- void promena(FILE *p, FILE *n, char x, char y) {
- int c;
- if (p == NULL || n == NULL) {
- printf("Datotekata ne postoi.\n");
- } else {
- while(c != EOF) {
- c = fgetc(p);
- if (c != EOF) {
- if (c != x) {
- fputc(c, n);
- } else {
- if (c == x) {
- fputc(y, n);
- }
- }
- }
- }
- }
- }
- int main(int argc, char *argv[]) {
- FILE *p;
- FILE *n;
- char x,y;
- printf("\n\nargc = %d\n\n", argc);
- x = argv[3][0];
- y = argv[4][0];
- printf("Ke se zamenat %c so %c\n\n", x, y);
- p = fopen(argv[1], "r");
- n = fopen(argv[2], "w");
- promena(p, n, x, y);
- fclose(p);
- fclose(n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment