Disclaimer: the following question is not for homework or a class assignment....just practice
I'm am trying to load an array with a file extension, based upon user input. The proper extension is present in the function, but when I print in main() to test, all I get is junk. This issue has been dogging me for a while, so I appreciate any feedback!
void choiceExt( char a[], int x );
int main() {
char fileExt[7];
choiceExt( fileExt, 4 );
// when printed here, extension is simply junk
cout << fileExt;
return 0;
}
void choiceExt( char a[], int x ) {
switch (x) {
case 1: a = ".txt";break;
case 2: a = ".out";break;
case 3: a = ".in";break;
case 4: a = ".dat";break;
case 5: a = ".ascii";break;
}
// when printed here, extension is good
cout << "ext is " << a << endl;
}