Re: App won't exit correctly
From: John Harrison (john_andronicus_at_hotmail.com)
Date: 03/31/04
- Next message: josh: "Re: static_cast signed to unsigned"
- Previous message: Aaron Gallimore: "square function"
- In reply to: ...: "Re: App won't exit correctly"
- Next in thread: John Harrison: "Re: App won't exit correctly"
- Reply: John Harrison: "Re: App won't exit correctly"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 31 Mar 2004 10:13:19 +0100
"..." <...@...> wrote in message
news:fd469b011f3208ab97e16cf1850ac94d@news.teranews.com...
>
>
> OK, Below is the code for the program I have written. It's purpose is to
> take an ISBN number as
>
> input and run it through as series of checks to confirm that it is a valid
> ISBN number. The last part
>
> of the function confirms if the check bit (last number) is correct as
> determined by the
>
> previous 9 numbers. The program seems to work fine; however, when compiled
> and run on a Unix
>
> box it doesn't seem to exit correctly.
>
>
>
> For anyone that is willing to offer help, I'm not just looking for
> corrections. I'd appreciate an explanation
>
> of where I have gone wrong and how I could improve my code.
>
Bit of mystery. I can see a few improvements, for instance this
int temp = atoi (&(identTest.c_str())[n]);
temp = temp / int(pow (10.0, (8.0 - n)));
can be replaced with the much simpler and more efficient
int temp = identTest[n] - '0';
Also you spend all that time returning a value from format_ok, but then you
never test that value in main. I would expect to see something like this
int main
{
...
if (format_ok(ISBNin))
cout << "the format is ok\n";
else
cout << "the format is bad\n";
}
rather than printing the message in format_ok.
But I can't see anything that would cause the problems you've described. It
compiles and runs correctly on my compiler. I'll test it on g++ when I get
the chance, which version of g++ are you using?
john
- Next message: josh: "Re: static_cast signed to unsigned"
- Previous message: Aaron Gallimore: "square function"
- In reply to: ...: "Re: App won't exit correctly"
- Next in thread: John Harrison: "Re: App won't exit correctly"
- Reply: John Harrison: "Re: App won't exit correctly"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|