Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

AbsolutDew

simple/stupid fstream help?

This topic is 5919 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

Hey, i got class that''s suppose to log messages to a file, but for some reason when i call OpenIMLog, Log, and CloseIMLog and then check the file, it''s totally blank. It does create the file though in the /log directory, and i am checking for return values. What am i doing wrong?
  
class CIMWatch
{
  fstream m_fsLog;
  string m_strBuddyName;
  ....

public:

  // Opens the log file

  bool OpenIMLog();
  // Closes the log file

  void CloseIMLog();
  // Logs the contents of the buffer

  bool Log( string strText );
  ....
};

bool CIMWatch::OpenIMLog()
{
  string strLogName = "Logs\\" + m_strBuddyName + ".txt";

  m_fsLog.open( strLogName.c_str(), ios::app | ios::out );
  if( m_fsLog.fail() )
    return false;

  m_fsLog << "Opening " << strLogName << endl;

  return true;
}

void CIMWatch::CloseIMLog()
{
  if( m_fsLog.is_open() )
    m_fsLog.close();
}

bool CIMWatch::Log( string strText )
{
  if( m_fsLog.is_open() )
  {
    m_fsLog << strText;

    return true;
  }

  return false;
}
  

Share this post


Link to post
Share on other sites
Advertisement
i am using just fstream and i tried the ios_base::app/out flags and still no go

[edited by - absolutdew on May 2, 2002 4:29:29 PM]

Share this post


Link to post
Share on other sites

  • 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!