PDA

View Full Version : ifstream failing, weird behavior



BettaUseYoNikes
24th August 2011, 20:55
QString FPath = "C:/Documents and Settings/wrightc/Desktop/TESTS/PBP001TEST.txt";
ifstream fin;
fin.open(FPath.toStdString().c_str(),ios::in|ios:: binary);
if (fin.fail())
{


}

That is my code to open the file for reading with the code inside the if statement ommitted, basically just outputs an error message and returns. I am so confused as to why it wouldn't be working because I am using the exact same code in another function in this class and it opens the file with no problems.
While debugging some weird linker messages are being outputted but I can't make anything of them

can't find linker symbol for virtual table for `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep' value
found `QPointer<QTextDocument>::~QPointer()' instead

mvuori
24th August 2011, 21:12
I don't know why that is, but... as this is a Qt forum, you _obviously_ should use Qt classes for working the files... Now you just use a piece of generic C++ (with a C string converted from a Qt string as input).

BettaUseYoNikes
24th August 2011, 21:48
I tried the exact same thing with the QFile Qt class and got the exact same result.

ChrisW67
24th August 2011, 23:17
The linker error message clearly has nothing at all to do with the code snippet you have shown us (it builds fine here). This is reinforced by your assertion that substituting the Qt classes for file access make no difference to the error output.

The message contains references to QTextDocument and QPointer. Start by looking for the places in your code where you are using these classes/objects.