How can i read a text file from a specified location?

closed account (16pXSL3A)
I have the text file written in X:\CPlusPlus.txt
I have program in the C:\Program.exe
How can i read a text file from a specified location?


ifstream infile("X:\\CPlusPlus.txt ");
closed account (16pXSL3A)
It doesn't work...

I don't know where's the file.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
char LOCATION;

for(int i = 65 ; i <= 90 ; i++)
{
      LOCATION = (char)i;

       ifstream FILE(LOCATION + ":\\CPlusPlus.txt");

       FILE.open();
       if(!FILE.eof())
       {  cout<<"error";  }
        else
       { cout<<"opened and is written"; }
       FILE.close();
}

Last edited on
Topic archived. No new replies allowed.