|
| atoi doesn't accept NULL argument |
 |
Sat, 23 Feb 2008 12:03:19 +020 |
Hello back:
Also I noticed that with version 5.5 "atoi" doesn't accept NULL
argument
is there something equivalent that accept it??
Regards
Maurice
|
| Post Reply
|
| Re: atoi doesn't accept NULL argument |
 |
Sat, 23 Feb 2008 19:24:32 +000 |
"Maurice" <morisaab@yahoo.fr> wrote:
>Also I noticed that with version 5.5 "atoi" doesn't accept NULL
argument
>is there something equivalent that accept it??
If you're treating NULLs as actual strings, you will keep falling over
these problems.
It's fairly easy to write quick little wrappers though:
inline int my_atoi(char const* text)
{
return text ? atoi(text) : 0;
}
(Returning a valid value when handed an invalid string is not what I'd
normally recommend, but you seem to want to.)
Alan Bellingham
--
Team Browns
<url:http://www.borland.com/newsgroups/> Borland newsgroup descriptions
|
| Post Reply
|
| Re: atoi doesn't accept NULL argument |
 |
Sun, 24 Feb 2008 09:10:57 +010 |
"Maurice" <morisaab@yahoo.fr> writes:
> Also I noticed that with version 5.5 "atoi" doesn't accept NULL
> argument is there something equivalent that accept it??
Testing for NULL before invoking functions that don't accept NULL
pointers (as Alan already wrote).
Also, note that atoi() is rarely a good choice, since strtol() offers
|
| Post Reply
|
| Re: atoi doesn't accept NULL argument |
 |
Mon, 25 Feb 2008 09:19:36 -050 |
Your stated problems are that the functions supplied by the language fail to
provide features which their specifications say that they do not provide.
The most productive path is to write your code in a manner which does not
require that functions have a behavior that they are specified to not have.
As Mr Bellingham is saying, when designing a program it is incumbent upon
the programmer to work with the features and limitations of the items which
he is using.
. Ed
> Maurice wrote in message
> news:47c283bc@newsgroups.borland.com...
>
> In fact, I'm moving my old programs to v5.5, atoi of v5.2 accept NULL
> arguments. It's the case of typing a command line with optional
> parameters. In some cases, I like that without parameters, the
> corresponding value was 0.
|
| Post Reply
|
| Re: atoi doesn't accept NULL argument |
 |
Mon, 25 Feb 2008 10:40:50 +020 |
"Alan Bellingham" <alanb@episys.com> wrote in message
news:bis0s3lb0pems1kh54lo2oc40rp8tbvuna@4ax.com...
> "Maurice" <morisaab@yahoo.fr> wrote:
>
>>Also I noticed that with version 5.5 "atoi" doesn't accept
NULL argument
>>is there something equivalent that accept it??
>
> If you're treating NULLs as actual strings, you will keep falling over
> these problems.
>
> It's fairly easy to write quick little wrappers though:
>
> inline int my_atoi(char const* text)
> {
> return text ? atoi(text) : 0;
> }
>
> (Returning a valid value when handed an invalid string is not what I'd
> normally recommend, but you seem to want to.)
>
> Alan Bellingham
> --
> Team Browns
> <url:http://www.borland.com/newsgroups/> Borland newsgroup
descriptions
> <url:http://www.borland.com/newsgroups/netiquette.html>
netiquette
Hi:
In fact, I'm moving my old programs to v5.5, atoi of v5.2 accept NULL
arguments. It's the case of typing a command line with optional parameters.
In some cases, I like that without parameters, the corresponding value was
0.
Thanks
Maurice
|
| Post Reply
|
|
|
|
|
|
|
|
|
|