I have written this code as part of a project. if my variable Name has the value "Amazon", how can i change this function so that the output is say Amazon.BAS if x=1.?
char* read(int x)
{
string s3;
switch (x)
{
case 1: s3=".BAS";break;
case 2: s3=".PAR";break;
case 3: s3=".DAT";break;
case 4: s3=".OBS";break;
case 5: s3=".RCH";break;
default:cout<<"wrong argument in read(arg)\n";
};
//Make string s1 contain value held by variable Name;
string s1;
stringstream out;
out << this->Name;
s1 = out.str();
string aFileS =s1+s3;
//convert filename string to Char
char aFile[100];
memset( aFile, '\0', 100 );//sets all values in char-array Radfile to "\0"
aFileS.copy( aFile, aFileS.size() );
cout<<aFile<<endl;
return aFile;
}