Code: Select all
void main()
{ ifstream myReadFile,x2;
ofstream myWriteFile;
char output[100],s[100];
myReadFile.open("2of12.txt");
x2.open("all_dict.txt");
int i,flag;
for( i = 0; i<100; i++, output[i] = '\0',s[i]= '\0');
if (myReadFile.is_open() && x2.is_open())
{
while(!myReadFile.eof())
{
flag = 0;
myReadFile >> output;
while(!x2.eof())
{ for( i = 0; i<100; i++, output[i] = '\0',s[i]= '\0');
x2>>s;
if(strcmp(s,output)==0) flag = 1;
}
x2.seekg(0,ios::beg); //reset read pos to beginning
x2.clear(); //clear eofbit
if(flag==0)
{
myWriteFile.open ("all_dict.txt",ios_base::app);
myWriteFile<<output<<endl;
myWriteFile.close();
myWriteFile.clear(); //clear eofbit
}
}
}
myReadFile.seekg(0,std::ios::beg); //reset read pos to beginning
myReadFile.clear(); //clear eofbit
myReadFile.close();
}
Code: Select all
Run-Time Check Failure #2 - Stack around the variable 's' was corrupted.
Advertising