Поиска в исходном текстовом файле слова max длины.Найденное слово переписать в новый файл.
ошибка:
fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
Помогите исправить.
Код:
#include "stdafx.h"
#include <conio.h>
#include <iostream>
#include <fstream>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "exception.cpp"
using namespace std;
class slovo
{
private:
char *str;
int kol_simvol;
public:
slovo()
{
str=new char[256];
};
~slovo(){};
bool flag;
void proc_sozdan_file(char *s);
void proc_poiska_slovo(char *s);
void proc_show_isx_file(char *s);
void proc_show_rez_file();
};
void slovo::proc_sozdan_file(char *s)
{
char namefile[8];
strcpy(namefile,s);
strcat(namefile,".txt");
try
{
ofstream f;
f.open(namefile,ios::out);
if (!f) throw (exception::ErrorSozdFile());
cout<<"Zapolnite file dannami"<<endl;
gets(str);
f.write((char *)&str,strlen(str));
cout<<"_____________________________________"<<endl;
cout<<" !!!file "<<namefile<<" sozdan"<<endl;
f.close();
}
catch(exception::ErrorSozdFile exp)
{
exp.Print();
flag=true;
};
void slovo::proc_poiska_slovo(char *s)
{
int i=0;
int probel=0;
int pozicion=0;
kol_simvol=0;
int p=0;
char namefile[8];
strcpy(namefile,s);
strcat(namefile,".txt");
try
{
ifstream f;
f.open("namefile",ios::in);
if (!f)
{
throw (exception::ErrorOpenFile());
}
f.read((char*)&str,strlen(str));
cout<<"______________________________________"<<endl;
cout<<endl;
cout<<"Dlinna_stroki: "<<strlen(str)<<endl;
for (i=0;i<=strlen(str);i++)
{
if ((str[i]==' ')||(i==strlen(str)))
{
if(kol_simvol<p)
{
kol_simvol=p;
pozicion=(i+1)-p;
p=0;
}
else
{
p=0;
}
}
else
{
p++;
}
}
cout<<"Kolich_max_simvolov: "<<kol_simvol<<endl;
cout<<"Pozicion_perv_simv : "<<pozicion<<endl;
cout<<"_________________________________________"<<endl;
f.close();
ofstream ftemp;
ftemp.open("ftemp.txt",ios::out);
if (!ftemp)
throw (exception::ErrorWriteFile());
for (i=pozicion-1;i<(pozicion-1)+kol_simvol;i++)
{
ftemp.write((char *)&str[i],1);
}
ftemp.close();
cout<<" !!!File ftemp.txt zapisan"<<endl;
cout<<"_____________________________________"<<endl;
}
catch(exception::ErrorOpenFile exp)
{
exp.Print();
}
catch(exception::ErrorWriteFile exp)
{
exp.Print();
};
void slovo::proc_show_isx_file(char *s)
{
char namefile[8];
strcpy(namefile,s);
try
{
ifstream f;
f.open("namefile",ios::in);
if (!f)
{
throw (exception::ErrorOpenFile());
}
f.read((char*)&str,strlen(str));
cout<<"Isxodniy file :";
cout<<""<<str<<endl;
f.close();
}
catch(exception::ErrorOpenFile exp)
{
exp.Print();
}
void slovo::proc_show_rez_file()
{
char *s;
s=new char[kol_simvol];
try
{
ifstream f;
f.open("ftemp.txt",ios::in);
if (!f)
{
throw (exception::ErrorOpenFile());
}
f.read((char *)s,kol_simvol);
cout<<"Rezultat file :";
cout<<""<<s<<endl;
cout<<"_________________________________________"<<endl;
f.close();
}
catch(exception::ErrorOpenFile exp)
{
exp.Print();
}
void main()
{
char namefile[8];
cout<<"Poryadok deistviu vipolneniya programmi "<<endl;
cout<<" Sozdaem i zapolnyaem file; "<<endl;
cout<<" Ischem slovo max dlinni; "<<endl;
cout<<" Zapisivaem slovo v noviuy file; "<<endl;
cout<<" Pechatyem isxodnyuy stroky; "<<endl;
cout<<" Pechatuem rezultat;"<<endl;
cout<<"_________________________________________"<<endl;
cout<<endl;
cout<<"Vvedite imya sozdovaemogo file"<<endl;
cin>>namefile;
// strcat(namefile,".txt");
class slovo max;
max.flag=false;
max.proc_sozdan_file(namefile);
if (max.flag)
{
cout<<"Exit"<<endl;
}
else
{
max.proc_poiska_slovo(namefile);
max.proc_show_isx_file(namefile);
max.proc_show_rez_file();
}
getch();
}
//Файл обработки исключительных ситуаций (exception.cpp)
#include "stdafx.h"
#include <iostream>
#include "exception.cpp"
using namespace std;
class exception
{
public:
//Класс ошибок при создании файла
class ErrorSozdFile
{
public:
void Print()
{
cout <<"!!!--->Error: File ne sozdan!<---!!!\n";
}
};
//Класс ошибок при открытии файла
class ErrorOpenFile
{
public:
void Print()
{
cout <<"!!!--->Error: File not open!<---!!!\n";
} //Класс ошибок при записи файла
};
class ErrorWriteFile
{
public:
void Print()
{
cout <<"!!!--->Error: File not write File!<---!!!\n";
}
//Класс ошибок при чтении файла
};
class ErrorReadFile
{
public:
void Print()
{
cout <<"!!!--->Error: File not read File!<---!!!\n";
}
};
};