Hello all..so i have this working bit of code..i made it to big and complex i think..and i was wondering if anyone had any insight on how i could compact it a little better..
let me explain . first i take the filename from argv[1].then i replace the .asm with a .lis. this then makes the filename source.lis.asm. so I erase the .asm extension to finally get source.lis. but my code seems a little ridiculous.haha . but any help would be cool. thanks.
argv[1]="source.asm "
string::iterato r it;
string str1=".lis";
string filename;
filename = *argv[1] ;
for (int r=0; r<filename.leng th(); r++)
{
filename= argv[1] ; //at this point i have source.asm
}
it=filename.end ()-4;
filename.replac e(it,filename.e nd()-4,str1); //at this point i have source.lis.asm
filename.erase( filename.end()-4); //now filename has source.lisasm
filename.erase( filename.end()-3); //now filename has source.lissm
filename.erase( filename.end()-2); //now filename has source.lism
filename.erase( filename.end()-1); //now filename has source.lis
let me explain . first i take the filename from argv[1].then i replace the .asm with a .lis. this then makes the filename source.lis.asm. so I erase the .asm extension to finally get source.lis. but my code seems a little ridiculous.haha . but any help would be cool. thanks.
argv[1]="source.asm "
string::iterato r it;
string str1=".lis";
string filename;
filename = *argv[1] ;
for (int r=0; r<filename.leng th(); r++)
{
filename= argv[1] ; //at this point i have source.asm
}
it=filename.end ()-4;
filename.replac e(it,filename.e nd()-4,str1); //at this point i have source.lis.asm
filename.erase( filename.end()-4); //now filename has source.lisasm
filename.erase( filename.end()-3); //now filename has source.lissm
filename.erase( filename.end()-2); //now filename has source.lism
filename.erase( filename.end()-1); //now filename has source.lis
Comment