Огромная просьба, если не сложно, объясните что "делает" каждая строка:
Код:
![Выделить весь код](images/misc/selectcode.png)
#include <io.h>
#include <string.h>
#include <fstream.h>
void Find();
int FindText();
void main()
{
* *Find();
}
int FindText (char filename[],char search[])
{
* *int k=0;
* *// НАЧИНАЯ ОТСЮДА
* *fstream fst (filename,ios::in|ios:: out|ios::app);
* *fst.close();
* *fst.open(filename,ios:: out|ios::in);
* *char buf [255];
* *while (fst.good())
* *{
fst.getline(buf,255);
* * * *if(strstr(buf,search)!=NULL)
{k=1;break;}
else
{k=0;}
* *}
* *fst.close();
return k;
}
void Find()
{
char path[150],path1[70],p[70];
cout <<"\nEnter path: ";
cin>>path;
strcpy(path1,path);
strcpy(p,path1);
char mask[15];
cout <<"\nEnter mask (for example, *.*, *.txt):";
cin>>mask;
char Ssearch[255];
cout<<"\nWhat word we shall search? ";
cin>>Ssearch;
strcat(path, mask);
_finddata_t *fileinfo=new _finddata_t;
* * * * long done = _findfirst(path,fileinfo);
int MayWeWork=done,kkk;
cout<<"\nInformation was found:\n\n";
while (MayWeWork!=-1)
{strcpy(path1,p); *
kkk=FindText(strcat(path1,fileinfo->name),Ssearch);
if (kkk==1)
{
* * * *cout<<"In file "<<fileinfo->name<<"\n";
}
MayWeWork=_findnext(done, fileinfo);
}
delete fileinfo;
cout<<"\n\n";
}