IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New It does
The original open() call was erroring out.

The code just didn't catch the error and was blithely assuming that the file existed and was open for I/O.

Tom Sinclair

"Man, I love it when the complete absence of a plan comes together."
- [link|http://radio.weblogs.com/0104634/|Ernie the Attorney]
New Erroring out?
I didn't see a try/catch construct in the code and you didn't mention the output so I figured it was silently failing and doing nothing.

Do you get an "uncaught exception" message?



"Packed like lemmings into shiny metal boxes.
Contestants in a suicidal race."
    - Synchronicity II - The Police
Expand Edited by tuberculosis Aug. 21, 2007, 05:40:03 AM EDT
New I checked the ios error flags
Basically I added a check for datafile.fail() and dumped it out if this returned true.

I only needed to verify if and where it was failing so exceptions would have been (to my mind) overkill.

When I checked the flags immediately after the open() call, the failbit flag was set but the original code didn't look for that so it went merrily on its way, assuming all was well.

As I said, this is code written by the textbook author and it apparently works without modification on Windows.
Tom Sinclair

"Man, I love it when the complete absence of a plan comes together."
- [link|http://radio.weblogs.com/0104634/|Ernie the Attorney]
New Thats not raising an exception
that's hiding an error code somewhere you have to go dig for it.

Its akin to returning an error code from a function - and of course nobody checks the return codes from functions - which is why exceptions were invented.



"Packed like lemmings into shiny metal boxes.
Contestants in a suicidal race."
    - Synchronicity II - The Police
Expand Edited by tuberculosis Aug. 21, 2007, 05:40:22 AM EDT
New Agreed
Exceptions are a better solution to the problem.
Tom Sinclair

"Man, I love it when the complete absence of a plan comes together."
- [link|http://radio.weblogs.com/0104634/|Ernie the Attorney]
     C++ File I/O: Windows vs. Linux - (tjsinclair) - (85)
         Wild guess - (JayMehaffey) - (1)
             Nope - (tjsinclair)
         Permissions problem? - (tuberculosis) - (16)
             Possibly - (tjsinclair) - (15)
                 The only dumb question is... - (jbrabeck) - (14)
                     Thanks - (tjsinclair) - (13)
                         I'd second the permissions... - (jbrabeck) - (12)
                             Played with error bits - (tjsinclair) - (11)
                                 C++ for real work - (tuberculosis) - (10)
                                     telco's use lots of c++ -NT - (boxley) - (7)
                                         on UNIX? - (tjsinclair) - (6)
                                             well several softswitches and other software (added link) - (boxley) - (2)
                                                 Yeah - OS level code I think - (tuberculosis) - (1)
                                                     Stacked based types? - (deSitter)
                                             some more info on c++ Unix and Telcos and jobs - (boxley) - (2)
                                                 CORBA == Objects, so makes sense - (tjsinclair)
                                                 Resume mailed -NT - (tuberculosis)
                                     Someone somewhere must be using it - (tjsinclair)
                                     Network Management software - (Arkadiy)
         I don't know C++ but... - (ben_tilly) - (6)
             Seems like it ought to raise an exception on failure -NT - (tuberculosis) - (5)
                 It does - (tjsinclair) - (4)
                     Erroring out? - (tuberculosis) - (3)
                         I checked the ios error flags - (tjsinclair) - (2)
                             Thats not raising an exception - (tuberculosis) - (1)
                                 Agreed - (tjsinclair)
         Got it! - (tjsinclair) - (58)
             Now, this is really scary - (Arkadiy) - (53)
                 Even scarier - (tjsinclair) - (52)
                     At this point, one wants to,, - (deSitter) - (3)
                         Ross, do we need a refresher... - (jb4) - (2)
                             I would completely agree with you except - (tjsinclair) - (1)
                                 Wow! - (jb4)
                     Which version of gcc? - (admin)
                     So, let me get this straight... - (Arkadiy) - (46)
                         Something like that, yes - (tjsinclair) - (44)
                             I've been trying to do that for years - (tuberculosis)
                             Barney is not responsible... - (jb4) - (42)
                                 Move farther up the food chain - (tuberculosis) - (41)
                                     OK, I'll bite... - (jb4) - (39)
                                         Errr... - (admin) - (34)
                                             I've heard strong typing called several different things... - (jb4) - (33)
                                                 Strict typing is like training wheels. - (admin) - (32)
                                                     Re: Strict typing is like training wheels. Or Helmuts? - (jb4) - (31)
                                                         You have much to learn - (tuberculosis) - (23)
                                                             Irony - (ben_tilly) - (22)
                                                                 Additionally... - (admin) - (21)
                                                                     That's the C++ propaganda - (tuberculosis) - (20)
                                                                         Wrong usage - (Arkadiy) - (7)
                                                                             Return value problem - (tuberculosis) - (6)
                                                                                 I'll take a look for the solution for ret value - (Arkadiy)
                                                                                 Re: Return value problem - (deSitter) - (4)
                                                                                     In the end - (Arkadiy) - (3)
                                                                                         A better statically typed language - have you tried Haskell? -NT - (ben_tilly) - (1)
                                                                                             Read the tutorials - (tuberculosis)
                                                                                         Today's link at /. - (Arkadiy)
                                                                         Interesting example, Todd - (jb4) - (11)
                                                                             Umm... - (Simon_Jester) - (5)
                                                                                 And what would you cast the void* back to afterwards? -NT - (tuberculosis) - (4)
                                                                                     Yeah, you'd have to test for the type... - (Simon_Jester) - (3)
                                                                                         Aaaaaahhhhhhh! - (tuberculosis) - (2)
                                                                                             *chuckle* - (Simon_Jester) - (1)
                                                                                                 Oh, you illustrated several problems - (tuberculosis)
                                                                             Your code should crash - (tuberculosis) - (4)
                                                                                 My code does crash, but not as often as you think. - (jb4) - (3)
                                                                                     Re: My code does crash, but not as often as you think. - (admin) - (1)
                                                                                         Replies coming - (jb4)
                                                                                     Re: My code does crash, but not as often as you think. - (tuberculosis)
                                                         Finally, something other than hand-waving. - (admin) - (6)
                                                             Hey I know Java - (tuberculosis) - (3)
                                                                 Whoops, forgot that one. - (admin) - (2)
                                                                     I always sit on a towel when using it - (tuberculosis) - (1)
                                                                         Interesting... I find I get more use out of... - (admin)
                                                             I've done it - (Arkadiy) - (1)
                                                                 Re: I've done it - (admin)
                                         How? - (tuberculosis) - (3)
                                             Erm? - (jb4) - (2)
                                                 GNU CPP version 2.95.2 19991024 (release) -NT - (tuberculosis) - (1)
                                                     Sorry to hear that...:-( - (jb4)
                                     Well said, exactly correct -NT - (deSitter)
                         This is frigging runtime lib bug, not language - (Arkadiy)
             You were mis-using the flags... - (Simon_Jester) - (3)
                 I thought of that - (tjsinclair) - (2)
                     For what it's worth, code also runs... - (a6l6e6x) - (1)
                         Figured that -NT - (tjsinclair)

Billion people harvest on Mars.
197 ms