Solved

Programming Stumper...

Posted on 2004-04-28
6
494 Views
Last Modified: 2006-11-17
The following code wasted 20 minutes of my time... Find the BUG!

// m_DEBUGFILE is in the class header as a CFile*
m_DEBUGFILE = new CFile();
CFileException fileException;

if ( !m_DEBUGFILE->Open( pszFileName, CFile::modeCreate | CFile::modeNoTruncate |
          CFile::modeReadWrite ), &fileException )
{
      // fileException.m_cause;
      delete m_DEBUGFILE;
      m_DEBUGFILE = NULL;
}
else
{
      m_DEBUGFILE->SeekToEnd();
      CString msg = "START DEBUGGING";
      m_DEBUGFILE->Write(msg,  msg.GetLength());
      m_DEBUGFILE->Write("\r\n", 2);
}

-- Thanks to microsoft for their wonderful API docs:
See: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/_core_opening_files.asp

-- Bubba
0
Comment
Question by:bganoush
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 3

Accepted Solution

by:
CoolBreeze earned 30 total points
ID: 10938440
lol.
this part does looks funny :)

if ( !m_DEBUGFILE->Open( pszFileName, CFile::modeCreate | CFile::modeNoTruncate |
          CFile::modeReadWrite ), &fileException )

the extra bracket
0
 
LVL 10

Assisted Solution

by:Mercantilum
Mercantilum earned 20 total points
ID: 10938856
In you if, the default 3rd argument of Open (exception) was set to NULL, and your if was always true, as in

  if (a, b, c)

the condition to be evaluated will be c.

The &fileException should have been in the Open statement,

  m_DEBUGFILE->Open( pszFileName, CFile::modeCreate | CFile::modeNoTruncate | CFile::modeReadWrite, &fileException)
0
 

Author Comment

by:bganoush
ID: 10939214

Good replies... and quick too!

Did you look at the sample code from Microsoft?   I always wondered why I can't copy some files ...  maybe microsoft actually based Windows on that sample?

-- Bubba
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:CoolBreeze
ID: 10939357
yup, looked at the sample code, the mistake was from the it.
I guess, probably they won't be basing on that code sample? after all, the documentation group is a different group from the coding group (I think).
0
 
LVL 10

Expert Comment

by:Mercantilum
ID: 10940099
Lol :)
It seems their sample are specifically written for the doc, as the Open would be always in error!
0
 
LVL 62

Expert Comment

by:☠ MASQ ☠
ID: 10943696
lol!
The bug is here -----> microsoft.com

M :o)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How many squares are in this diagram? 19 10,056
a word that means 'to make available to all' 14 601
Need help understanding this code 15 797
Maths Spiral grid co-ordinates formula 16 683
When using a search centre, I'm going to show you how to configure Sharepoint's search to only return results from the current site collection. Very useful when using Office 365 with multiple site collections.
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question