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
| #include "stdio.h"
#include "stdlib.h"
#include "ctype.h"
int main(void){
FILE * fi, * fo;
if ((fi = fopen("test.txt", "rt")) == NULL) {
puts("Cannot open input file.\n");
system("pause");
return 1;
}
if ((fo = fopen("test_out.txt","wt")) == NULL) {
puts("Cannot create output file.\n");
system("pause");
return 1;
}
char n;
fscanf( fi, "%c", &n );
while( !feof(fi) ) {
if ((n == '-')){
fscanf(fi, "%c",&n);
if (isdigit(n))
fprintf( fo, "%c", n );
else
fprintf(fo,"%c%c",'-',n);
fscanf( fi, "%c", &n );
}else{
fprintf( fo, "%c", n );
fscanf( fi, "%c", &n );
}
}
fclose(fi);
fclose(fo);
system("pause");
return 0;
} |