title: Could someone explain C++ escape character " \ " in relation to Windows file system?
body: <p>I'm really confused about the escape character " \ " and its relation to the windows file system. In the following example:</p>
  
  <pre><code>char* fwdslash = "c:/myfolder/myfile.txt";
  char* backslash = "c:\myfolder\myfile.txt";
  char* dblbackslash = "c:\\myfolder\\myfile.txt";
  
  std::ifstream file(fwdslash); // Works
  std::ifstream file(dblbackslash); // Works
  std::ifstream file(backslash); // Doesn't work
  </code></pre>
  
  <p>I get what you are doing here is escaping a special character so you can use it in this string. In no way by placing a backslash in a string literal or std::string do you actually change the string --- </p>
  
  <p>---Edit: This is completely wrong, and the source of my confusion--- </p>
  
  <p>So it seems that the escape character is only treated by certain classes or things to mean something other than a backslash, like outputting on the console, ie., std::cout &lt;&lt; "\hello"; will not print the backslash. In the case of ifstream (or I'm not sure if the same applies with the C fopen() version), it must be that this class or function treats backslashes as escape characters. I'm wondering, since the Windows file system uses backslashes wouldn't it make sense for it to accept the simple string with backslashes, ie., "c:\myfolder\myfile.txt" ?  Trying it this way fails. </p>
  
  <p>Also, in my compiler (Visual Studio) when I include headers I can use .\ and ..\ to mean either the current folder, or the parent folder. I'm pretty sure the \ in this isn't related to the escape character, but are these forms specific to Windows, part of the C preprocessor, or part of the C or C++ language? I know that backslashes are a Windows thing, so I can't see any reason another system would expect backslashes even when using .\ and ..\ </p>
  
  <p>Thanks.</p>