I'm trying to use back slash in C++ in a string like this :
HWND hwnd = FindWindowA(NULL, "C:\Example\App.exe");
So for this example I would get these errors/warnings :"unknown escape sequence: '\E'" "unknown escape sequence: '\A'" . Since I need to type in the exact name of the window , is there any way to avoid using back slashes or stop the compiler from interpreting them as "escape sequences" ?
You have to escape them properly, C++11 added raw string which eases this thing:
HWND hwnd = FindWindowA(NULL, R"(C:\Example\App.exe)");
else do it manually:
HWND hwnd = FindWindowA(NULL, "C:\\Example\\App.exe");
You should escape that properly:
HWND hwnd = FindWindowA(NULL, "C:\\Example\\App.exe");
For a full list of all escape sequences, check this:
https://en.cppreference.com/w/cpp/language/escape
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With