[fpc-devel] Comparing arrays of char

Carsten Bager carsten at beas.dk
Mon Nov 2 12:07:28 CET 2009


> In our previous episode, Carsten Bager said:
> > Here is output from my program p compiled with Delphi (5) and FPC.
> > I believe that FPC fails because the first byte is chr(0)  when comparing 70501033728 with 
> > 0.
> 
> Did you also try this on a PC? I haven't really tested, but it
> seems that you are converting between integers and arrays making use of
> their memory storage.
> 
> The memory storage format differs between x86 and (typical) arm. The former
> is little endian, the latter mostly bigendian.
It is the same on a PC

As far as I can see, the problem is the compiler does not differ between an 
array of char and a null terminated string.
As a result of this, if the first byte/char are 0 in both arrays the compiler 
stops checking and says that there are equal.  

Carsten




Carsten



More information about the fpc-devel mailing list