SA-MP Forums Archive
Which macro is correct for strcpy? - 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: Which macro is correct for strcpy? (/showthread.php?tid=516254)



Which macro is correct for strcpy? - Riwerry - 30.05.2014

What is correct macro for strcpy? In YSI (y_utils) I can see:

pawn Код:
#define strcpy(%0,%1) strcat((%0[0] = '\0', %0), %1)
But here on forums I found:

pawn Код:
#define strcpy(%0,%1,%2) strcat((%0[0] = '\0', %0), %1, %2)
What is difference?


Re: Which macro is correct for strcpy? - Konstantinos - 30.05.2014

The second is the correct because you have to specify the max length. If you try the first one with an array from an enum, it will be NULL.


Re: Which macro is correct for strcpy? - Vince - 30.05.2014

Would much rather wrap it in a function so the third argument can have a default sizeof expression. This allows both versions to be used. I never quite understood the obsession with macros anyway.


Re: Which macro is correct for strcpy? - Riwerry - 30.05.2014

Okay, thanks ****** now I understand.