[Include] "stringh.inc": Implementing useful functions from C's "string.h"
#13

You cannot simply do something like for example
pawn Код:
#define strncpy(%0,%1,%2,%3) \
                        new cchar[] \
                        ;strmid(char,%1,0,((%2)-1)) \
                        ;strdel(char,%2,strlen(char)) \
                        ;strcat((%0[0] = '\0', %0),char,%3)
since macros are basicly text replacements and, if you try to use such macro twice in your script
pawn Код:
public someCallback()
{
    new some_array[4], some_array_2[4];
    strncpy(some_array, "foo", 2, sizeof some_array); // not the same "sizeof" we know from C/C++
    strncpy(some_array_2, "bar", 2, sizeof some_array_2);
}
becomes
pawn Код:
public someCallback()
{
    new some_array[4], some_array_2[4];
    new cchar[];
    strmid(char, "foo",0,(( 2)-1));
    strdel(char, 2,strlen(char));
    strcat((some_array[0] = '\0', some_array),char, sizeof some_array);
    new cchar[];
    strmid(char, "bar",0,(( 2)-1));
    strdel(char, 2,strlen(char));
    strcat((some_array_2[0] = '\0', some_array_2),char, sizeof some_array_2);
}
will give you compiling errors, like that you've not declared the size of a "cchar" array and redeclaration of a "cchar" array.
Reply


Messages In This Thread
"stringh.inc": Implementing useful functions from C's "string.h" - by Aeonosphere - 18.05.2013, 01:22
Re: "stringh.inc": Implementing useful functions from C's "string.h" - by RajatPawar - 18.05.2013, 04:37
Re: "stringh.inc": Implementing useful functions from C's "string.h" - by Niko_boy - 18.05.2013, 06:53
Re: "stringh.inc": Implementing useful functions from C's "string.h" - by Aeonosphere - 18.05.2013, 07:55
AW: "stringh.inc": Implementing useful functions from C's "string.h" - by BigETI - 18.05.2013, 08:01
Re: "stringh.inc": Implementing useful functions from C's "string.h" - by Emmet_ - 18.05.2013, 08:02
AW: Re: "stringh.inc": Implementing useful functions from C's "string.h" - by BigETI - 18.05.2013, 08:12
Re: AW: Re: "stringh.inc": Implementing useful functions from C's "string.h" - by Aeonosphere - 18.05.2013, 08:15
Re: AW: Re: "stringh.inc": Implementing useful functions from C's "string.h" - by Emmet_ - 18.05.2013, 08:17
Re: AW: Re: "stringh.inc": Implementing useful functions from C's "string.h" - by Aeonosphere - 18.05.2013, 08:23
Re: AW: Re: "stringh.inc": Implementing useful functions from C's "string.h" - by Emmet_ - 18.05.2013, 08:31
Re: "stringh.inc": Implementing useful functions from C's "string.h" - by Aeonosphere - 18.05.2013, 08:46
AW: "stringh.inc": Implementing useful functions from C's "string.h" - by BigETI - 18.05.2013, 10:04
Re: AW: "stringh.inc": Implementing useful functions from C's "string.h" - by Aeonosphere - 18.05.2013, 11:10
AW: "stringh.inc": Implementing useful functions from C's "string.h" - by BigETI - 18.05.2013, 14:50
AW: Re: "stringh.inc": Implementing useful functions from C's "string.h" - by BigETI - 18.05.2013, 20:06
AW: "stringh.inc": Implementing useful functions from C's "string.h" - by BigETI - 18.05.2013, 20:23
AW: "stringh.inc": Implementing useful functions from C's "string.h" - by BigETI - 18.05.2013, 20:43
AW: "stringh.inc": Implementing useful functions from C's "string.h" - by BigETI - 18.05.2013, 21:55
AW: "stringh.inc": Implementing useful functions from C's "string.h" - by BigETI - 18.05.2013, 22:35

Forum Jump:


Users browsing this thread: 1 Guest(s)