Back slash causing problems c++

  • A+
Category:Languages

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"); 

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: