[Info-vax] Significance of 2020 / 2021 date
John Dallman
jgd at cix.co.uk
Sat Jan 9 08:52:00 EST 2021
In article <i5tpv6Fnj2hU1 at mid.individual.net>, bill.gunshannon 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
More information about the Info-vax
mailing list