Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Курсовик1
.CPP#include <stdio.h>
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
FILE *mfclose(FILE *fl)
{
fclose(fl);
return 0;
};
int main(void)
{
FILE *fl1=NULL,*fl2=NULL;
char *name,buf1,buf2;
int br=0;
for(char r='y';r=='y';)
{
clrscr();
while(fl1==NULL)
{
printf("Enter name of source file: \n >");
gets(name);
if((fl1=fopen(name,"r"))==NULL)
{
perror("While file was opening, there were some errors");
printf("\n Restart program (y/n) \n >");
scanf("%c",&r);
if(r=='n') return 0;
};
};
printf("\n\n***Sourse file :: %s ***\n\n",name);
while(buf1!=EOF)
printf("%c",buf1=getc(fl1));
fl1=mfclose(fl1);
fl1=fopen(name,"r");
buf1=' ';
printf("\n\n\n***Modified text***\n\n");
while(buf1!=EOF)
{
buf1=getc(fl1);
br+=(buf1=='(');
br-=(buf1==')');
if(br==0||((buf1<47)&&(buf1>58)||(buf1<64)&&(buf1>123)))
if(buf1!=')')
if(buf1!=EOF)
printf("%c",buf1);
};
fl1=mfclose(fl1);
printf("\n\n\n***Save this modified text? (y/n) \n >");
cin>>r;
if(r=='y')
{
fl2=fopen(name,"r");
while(fl1==NULL&&r=='y')
{
printf("Enter name of new file to save modified text: \n >");
gets(name);
if((fl1=fopen(name,"w"))==NULL)
{
perror("While file was rewriting, there were some errors");
printf("\n Repeat enter file name (y/n) \n >");
scanf("%d",&r);
};
};
buf1=' ';
if(r=='y')
{
printf("\n\n***Saved file :: %s ***\n\n",name);
while(buf1!=EOF)
{
buf1=getc(fl2);
br+=(buf1=='(');
br-=(buf1==')');
if(br==0||((buf1<47)&&(buf1>58)||(buf1<64)&&(buf1>123))&&buf1==')')
if(buf1!=')')
if(buf1!=EOF)
{
printf("%c",buf1);
putc(buf1,fl2);
};
};
fl1=mfclose(fl1);
fl2=mfclose(fl2);
};
};
printf("\n\n\nRepeat start of program (y/n) \n >");
cin>>r;
};
return 0;
};
Соседние файлы в предмете Программирование