include stdio define 255 void delete char str int begin int lng while

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <stdio.h>
#define N 255
/*4.1*/
void delete(char *str, int begin, int lng) {
while(*(str + begin++ - 1) = *(str + begin + lng - 1));
}
int main(int argc,char* argv[]) {
FILE *f1, *f2 = 0;
int k = 0;
char str[N];
int i,j = 0;
char simbol = 0;
printf("\nVvedite simbol:\n");
scanf("%c", &simbol);
printf("Vvedite im9 vxodnogo faila:\n");
scanf("%s", argv[0]);
argv[1] = "laba4in.doc";
f1 = fopen(argv[0], "r");
if (f1 == NULL) printf("Error!");
f2 = fopen(argv[1], "w");
if (f2 == NULL) printf("Error!");
if ((f1 != NULL) && (f2 != NULL)) {
while (fgets(str,N,f1) != NULL) {
for (i = 0; i < (strlen(str)-1); i++) {
if (str[i] == simbol) {
delete(str, 0, strlen(str)-1);
}
}
fputs(str, f2);
}
}
fclose(f2);
fclose(f1);
return 0;
}
#include <stdio.h>
/*4.2*/
int main(int argc,char* argv[]) {
FILE *f1, *f2 = 0;
int k = 0;
char c;
argv[1] = "laba4out.txt";
printf("Vvedite im9 vxodnogo faila:\n");
scanf("%s", argv[0]);
f1 = fopen(argv[0], "r");
if (f1 == NULL) printf("Error!");
f2 = fopen(argv[1], "w");
if (f2 == NULL) printf("Error!");
if ((f1 != NULL) && (f2 != NULL)) {
while ((c = fgetc(f1)) != EOF) {
if (c == ' ') {
fputc(c, f2);
fputc('.', f2);
k++;
}
else fputc(c, f2);
}
printf("\nKolvo vstavok %d", k);
}
fclose(f2);
fclose(f1);
return 0;
}