[Warning] unknown escape sequence: '\D' [enabled by default]

Thought I had it but now I'm getting an error I don't understand.. Halp!
20 [Warning] unknown escape sequence: '\D' [enabled by default]


#include <iostream>
#include <fstream> //allows files to be streamed into this program


using namespace std;


int main ()
{
int N=0;
int M=0;
double T=0.0;
double A=0.0;
//N=Number
//M=Number of numbers
//T=Total of all numbers
//A=Average of numbers



ifstream inputFile;
inputFile.open("C:\Users\Eevee\Documents\randomnumbersc++.docx");

if (inputFile.fail())
cout << "Sorry, I couldn't find the file.";
else
{

while (inputFile >> N)
{
M++;
T+=N;
}

if (M>0)
A = T/M;
else
A=0.0;

cout << "There are " << M << " numbers in this file.\n";
cout <<"There are" << T << "when added together.\n";
cout << A << "is the average number in your file.";

}

inputFile.close();
system ("pause");
return 0;
}
In a C++ string, the "\" character is used to enter special characters. Think '\n' for example. Unfortunately, microsoft also chose this character to separate directories in a path. So in this string "C:\Users\Eevee\Documents\randomnumbersc++.docx" each '\' is an escape and the string that actually gets compiled is not what you expect.

To solve this, you have to escape the \ character itself. Change the string to "C:\\Users\\Eevee\\Documents\\randomnumbersc++.docx"
Just FYI: Windows core functions accepts forward slash '/' as directory separator. However they do not accept it in command line, so you should not use it with, say, system() calls.
Topic archived. No new replies allowed.