Jump to content
  • Advertisement
Sign in to follow this  
Lykaios

Can't get ofstream to open or write!

This topic is 3977 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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;

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!