filestream failbit


So, I have a problem with my ifstream, it would seem: even though the file path
is legit, ifstream throws a failbit. Does anyone have a clue what may be the problem, or ideas on general I/O newbie pitfalls? It would be much appreciated!

1
2
3
4
5
6
7
8
9
10
11
ifstream input("C:\text.txt");

string line;

if (input.fail())
    cout << "Fail!";

else {
    while (getline(input,line))
        cout << line;
}
closed account (1vRz3TCk)
try: "C:\\text.txt"
closed account (DSLq5Di1)
"C:\text.txt" will be translated to "C:    ext.txt"

Reference for escape sequences:-
http://msdn.microsoft.com/en-us/library/h21280bw
You'll also find that

ifstream input("C:/text.txt");

text works fine on systems that use \ in their command line, such as Windows. It has the added benefit of being cross-platform.
Fffffffffffffffff! Forgot 'bout that!!

thank you guys!
Topic archived. No new replies allowed.