SA-MP Forums Archive
Is NULL the same as zero? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Is NULL the same as zero? (/showthread.php?tid=473421)



Is NULL the same as zero? - Baltazar - 02.11.2013

Let's say I have declared an array and initialized first two slots of it with zeros:
Код:
#define NULL '\0'
new array[5] = { 0, 0, NULL, NULL, NULL };
I loop through it now:
Код:
for(new i=0; array[i]!=NULL; i++)
  printf("%i", array[i]);
Is it going to print two zero elements or maybe it assumes zeros are the same as NULL elements? Thanks
btw, can't check it myself now, sorry


Re: Is NULL the same ase zero? - Patrick - 02.11.2013

In Scripting/Coding term, NULL is equals to 0


Re: Is NULL the same as zero? - Mauzen - 02.11.2013

In this case NULL is 0, as \0 is the ascii escape character for 0. But in general it isnt. Null often is an own "third" state that means some value is not defined.
E.g. in OO programming it is commonly used as default value for uninitialized objects. So an object is NULL until you actually create it. This again references to 0 as "false" memory reference, but it means slightly more than just this.