ok so i made a code that makes something compatible with a never version ( it is not important). This is my code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main ()
{
char File[150], re[4];
string line[5000];
string response;
int counter=0;
size_t found;
string strtofind[]={"oolean1", "oolean2", "oolean3", "nteger1", "nteger2", "nteger3",
"tring1", "tring2", "tring3"};
string changestr[]={"ooleans[0]", "ooleans[1]", "ooleans[2]", "ntegers[0]", "ntegers[1]",
"ntegers[2]", "trings[0]", "trings[1]", "trings[2]"};
int index;
cout<<" Script Converter\n";
cout<<"Would you like to convert a SRL 3.81 script to SRL 4? (yes or no) \n";
cin>>re;
_strupr_s(re);
response=re;
if(response== "YES") {
cout<<"Please enter the name of the file (C:/Program Files/example.scar)"<<endl;
cout<<"the location is not needed if this program and the script are in the same folder\n";
cin.ignore ( 150, '\n' ); //flush the input stream
cin.getline(File, 150);
cout<<"Now Converting "<< File<< " to SRL 4 ..."<<endl;
ifstream fin;
ofstream fout;
fin.open(File);
if(fin){
while (getline(fin, line[counter])){
counter++;
}
for(counter=0; counter<5000; counter++){
for(index=0; index<11; index++){
found=line[counter].find(strtofind[index]);
if (found!=string::npos){
line[counter].replace(int(found), strtofind[index].length(), changestr[index]);
}
}
}
fout.open(File);
fout<<"{Script Converted to SRL 4 by Macrosoft's Script Converter}\n";
for(counter=0; counter<5000; counter++){
fout<<line[counter]<<"\n";
}
cout<<"Finished converting script\n";
}
else {
cout<<"Failed to open file\n";
}
fin.close();
fout.close();
}
else if(response == "NO"){
cout<<"Closing Program...\n";
}
else{
cout<<"Response not understood. Closing Program...\n";
}
system("PAUSE");
return 0;
}
it works fine when i debug (i use ms visual C++). But when i use the build version, it always "encounters a problem" and has to close. If someone knows why this is happening, that would be great.
Thanks in advance