26.12.2013, 18:53
(
Последний раз редактировалось Patrick; 26.12.2013 в 19:52.
)
string.clear, C++ string.clear function into sa-mp
Macro/Code
Example Code
Result
Have a nice day!
EDIT: Thanks to Konstantinos for his Smart Idea
Usage
Macro/Code
pawn Код:
#define string.clear(%0) \
%0[0] = EOS
//or
#define string.clear(%0) \
%0[0] = '\0'
pawn Код:
#include <a_samp>
#define string.clear(%0) \
%0[0] = EOS
#define isnull(%1) \
((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
new string[21] = "Hello, SA-MP Forums.";
main()
{
SetTimer("ClearString", 2000, false);
if(isnull( string ) )
{
return printf("Before: %s | = %i | Not Null", string, string);
}
return true;
}
forward ClearString();
public ClearString()
{
string.clear(string);
if(isnull( string ) )
{
return printf("After: %s | = %i | Null", string, string);
}
return true;
}
Код:
Before: Hello, SA-MP Forums. | 72 | Not Null After: | 0 | Null
EDIT: Thanks to Konstantinos for his Smart Idea
pawn Код:
#define clear.%0() (%0[0] = '\0')
Код:
clear.str[0/*0 .. 128 and so on*/]();
