08.11.2010, 19:23. Просмотров 341. Ответов 6
Программа должна прочитать текст из файла, записать тот же текст в другой файл, заменив точки на запятые, а запятые на ...(три точки)программа компилится, но при запуске выдает непонятную ошибку.
C++ |
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
| #include "stdafx.h"
#include <stdio.h>
#include <string>
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{int c, retval;
FILE *ifl, *ofl;
ifl=fopen("txt.txt", "r");
ofl=fopen("output.txt", "w");
if (ifl=NULL)
cout<<"Ошибка открытия файла";
else{
while ((c=getc(ifl))!=EOF)
{
if (c=='.')
retval=putc(',', ofl);
else if (c==',')
retval=fputs("...", ofl);
else
retval=putc(c, ofl);
if (retval==EOF)
break;
}
if (c!=EOF && retval==EOF)
fprintf(stderr, "Ошибка при записи в файл" "\n");
}
return 0;
}
} |
|