Attemping to convert Int to Const Char

I've tried a few different methods that i've found on the internet, but none have worked so far.
I'm attempting to save multiple files being lead by a string from within the program, based on the integer of a global variable.

I've tried something with Casting, Tried itoa and messed with pointers, None of them worked.

Most of the time, The compiler gives me an error of invalid conversion,
or the program crashs when I attempt to use the function.

I've ran out of ideas and came here hoping for some guidance.


int filenumber = 003; // Global Variable

char ThisArray[50];
char portstring = (char)filenumber;
const char * portstring = reinterpret_cast<const char *>(portstringconst);

strcpy( ThisArray, "data\\file");
strcat( ThisArray, portstringconst);
strcat( ThisArray, ".txt");

SaveFile(ThisArray);
Last edited on
Casting won't work.

See this: http://www.cplusplus.com/forum/articles/9645/

Also, strings are easier to work with than char arrays.
It took some time, But I have it working now, Thank you for the reference.
Topic archived. No new replies allowed.