Original Post
Hello, I am building a GUI in directX, and using some simple text initialisation files to build the GUI at startup. I wondered if it was possible to do something similar to a switch statement, but with strings? for instance fscanf( pFile, "%s", typeStr ); switch ( typeStr ) { case "button": // etc } At the moment, the compiler says switch expression of type 'std::string' is illegal Same thing with char arrays. As a result I am using a number instead of the string, but its not very friendly. I knwo I could use this: #define BUTTON 0 fscanf( pFile, "%d", type ); switch ( type ) { case BUTTON: // etc } but its still a zero in the txt file, not a string! Any advice gratefully received! Thanks Simon