Alice Alice - 2 months ago 19
C++ Question

Why am I getting an "unknown escape character" error for this code

This code is throwing the error

warning: unknown escape sequence: '\040' [enabled by default]

std::cout << "\nPlease choose a race:\n"
"1. Elf\ n"
"2. Human\n"
"3. Vampire\n"
"4. Druid\n"
"5. Troll\n"
"6. Orc\n"
"7. Dwarf\n"
"8. Race Info\n" ;

No idea why this is happening, any help would be appreciated.


Because the literal "\ n" is not a valid escape sequence. 040 represents a space in what I'm assuming is octal. You need to change 1. to "\n"