The code is supposed to concatenate argv[1] with .txt , and with _r.txt .
std::stringstream sstm;
std::stringstream sstm_r;
sstm<<argv[1]<<".txt";
sstm_r<<argv[1]<<"_r.txt";
const char* result = sstm.str().c_str();
const char* result_r = sstm_r.str().c_str();
fs.open(result);
fs_r.open(result_r);
cout<<result<<endl;
cout<<result_r<<endl;
But what it does is , when i enter "abc" as argv[1] , it gives me , result as "abc_r.tx0" and result_r also same "abc_r.tx0" .What is the correct way to do this and why is this wrong .