Re: atoi return
- From: "Bill Cunningham" <nospam@xxxxxxxxxxxxx>
- Date: Fri, 10 Oct 2008 18:16:59 -0400
"Keith Thompson" <kst-u@xxxxxxx> wrote in message
news:ln4p3lm0yy.fsf@xxxxxxxxxxxxxxxxxx
Yes.
Take a look at the following program and tell me how you'd detect an
error in a call to atoi().
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char *good = "0";
char *bad = "bad";
printf("atoi(\"%s\") = %d\n", good, atoi(good));
printf("atoi(\"%s\") = %d\n", bad, atoi(bad));
return 0;
}
I can't really read that Keith but if I remember right this was
mentioned before but never really explained. I would've tried something
like this if it's even valid.
....
int i;
if (i=atoi(argv[1]))!=sizeof(int))
fprintf(stderr,"error\n");
*sigh* I dunno. Does this make any sense?
Bill
.
- Follow-Ups:
- Re: atoi return
- From: Keith Thompson
- Re: atoi return
- References:
- atoi return
- From: Bill Cunningham
- Re: atoi return
- From: Keith Thompson
- atoi return
- Prev by Date: Re: Returning a struct from a function - strange behavior
- Next by Date: Re: thousands of request in one port per second
- Previous by thread: Re: atoi return
- Next by thread: Re: atoi return
- Index(es):
Relevant Pages
|