[Info-vax] Significance of 2020 / 2021 date
abrsvc
dansabrservices at yahoo.com
Sat Jan 9 10:40:11 EST 2021
On Saturday, 9 January 2021 at 08:52:56 UTC-5, John Dallman wrote:
> In article <i5tpv6... at mid.individual.net>, bill.gu... at gmail.com
> (Bill Gunshannon) wrote:
> > On 1/9/21 8:27 AM, Bill Gunshannon wrote:
> > > On 1/9/21 7:35 AM, Andy Burns wrote:
>
> >>>>> if (atoi (date_string + 5)> 2020)
> > >> atoi requires a *pointer* to an asciiz string, presumably in
> > >> this case the format is something like DDMMMYYYY, so that the +5
> > >> starts the decimal conversion from the address of the first Y.
> > > I would have expected the original to generate an error at compile
> > > time.
>
> > OK, it made me curious enough that I tried a few examples.
> > Apparently the compiler (at least gcc) doesn't really care what you
> > throw at the call to atoi().
> It takes a char* pointer, and assumes the string is terminated by a zero
> byte. The +5 is just moving the pointer along by 5 characters, producing
> a new pointer.
>
> This is perfectly legal C code. Not good modern style, but entirely legal.
>
>
> John
Please note as well that the initial problem statement indicated that date_string was an array.
I would assume that it is an array of characters and that date_string+5 points to the year portion as John suggested.
More information about the Info-vax
mailing list