Can't get ofstream to open or write!

Started by
1 comment, last by swiftcoder 16 years, 4 months ago
This is just plain weird. I have a thread in which I have included fstream and created an ofstream. I know the lines are being executed because I have set breakpoints and they get hit. But no file opening, and nothing writing?!! TetClientSink.h:

#include "trackedWindow.h"
#include <fstream>
using namespace std;

... //other declarations

ofstream tetFile;
TetClientSink.cpp

CTetClientSink::CTetClientSink(CTrackedWindow *pTrackedWindow)
{
	m_dwRef = 0;
	m_pTrackedWindow = pTrackedWindow;
	tetFile.open("eyeLog.out", ios::app);
	tetFile << "I'm here!";
	tetFile.flush();
}
Does this possibly have anything to do with the fact it's a thread? That's the one aspect of this code I don't feel I have a perfect understanding of. Let me know if posting the fstream buffer contents before/after any of the tetFile code. thanks ~Lykaios
Advertisement
probably "eyeLog.out" does not exist, or it does not find it because the working directory variable is not what you think, causing the append file stream to cancel?
Quote:Original post by yahastu
probably "eyeLog.out" does not exist, or it does not find it because the working directory variable is not what you think, causing the append file stream to cancel?

Or you don't have write access to the file.

However, i seem to recall this should cause an error when you try to write to the file. Since it isn't, you might try testing the file after opening, like this:
 If (!tetFile) std::cerr << "PANIC!" << std:endl;

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

This topic is closed to new replies.

Advertisement