I would like to convert from #define to string.
My code:
#ifdef WIN32
#define PREFIX_PATH = "..\\"
#else
#define PREFIX_PATH = "..\\..\\"
#endif
#define VAL(str) #str
#define TOSTRING(str) VAL(str)
string prefix = TOSTRING(PREFIX_PATH);
string path = prefix + "Test\\Input\input.txt";
But, it didn't work..
prefix value is "..\\\"
Any idea what is the problem..
Thanks!
string prefix = PREFIX_PATH;string prefix = PREFIX_PATH;PREFIX_PATHis already defined as a quoted string, but it is passed throughVAL, which tries to quote the symbol again, with#. Also, note that non-Windows OS's usually use forward slashes, not backslashes as a path separator.