Frustrating sscanf problem. -
Famalamalam - 05.08.2011
Quote:
[00:12:06] sscanf warning: Strings without a length are deprecated, please add a destination size.
[00:12:06] sscanf warning: Strings without a length are deprecated, please add a destination size.
|
Now, this has been happening forever, I am at a loss as to solve it, here is what causes it:
pawn Код:
new mSubCommand[5], mCommand[20], m3rdCommand[20], string[128], pDeaths, h, m, s, file[MAX_PLAYER_NAME];
if(sscanf(params, "s[20]S(5)S(20)", mCommand, mSubCommand, m3rdCommand))
Under this command are several sub commands, and sub-sub commands (for lack of a better word..), any help is hella appreciated.
Re: Frustrating sscanf problem. -
[HiC]TheKiller - 05.08.2011
pawn Код:
if(sscanf(params, "s[20]S[5]S[20]", mCommand, mSubCommand, m3rdCommand))
Re: Frustrating sscanf problem. -
Famalamalam - 05.08.2011
Lol, I tried that before posting (I've tried everything I can think of) that spits out some weird error, sec let me get it from logs:
Quote:
[19:29:49] sscanf warning: No default value found.
[19:29:49] sscanf warning: Unknown format specifier '[', skipping.
[19:29:49] sscanf warning: Unknown format specifier '4', skipping.
[19:29:49] sscanf warning: Unknown format specifier ']', skipping.
[19:29:49] sscanf warning: No default value found.
[19:29:49] sscanf warning: Unknown format specifier '[', skipping.
[19:29:49] sscanf warning: Unknown format specifier '2', skipping.
[19:29:49] sscanf warning: Unknown format specifier '0', skipping.
[19:29:49] sscanf warning: Unknown format specifier ']', skipping.
[19:29:49] sscanf warning: Format specifier does not match parameter count.
|
Re: Frustrating sscanf problem. -
Vince - 06.08.2011
When using the optional string specifier (S) you need to put a default value AND a string size; the correct format is:
pawn Код:
if(sscanf(params, "s[20]S(default text 1)[5]S(default text 2)[20]", mCommand, mSubCommand, m3rdCommand))
Re: Frustrating sscanf problem. -
Famalamalam - 06.08.2011
Oh, ok.... but what would the default text be? I'm confused.
Re: Frustrating sscanf problem. -
Vince - 06.08.2011
The default text is filled in by sscanf if it is not specified by the user. If you're not planning to use the default text, you should just use the normal string specifier (s) instead of the optional string. Simplified example would be:
pawn Код:
if(sscanf(params, "uS(No Reason Specified)[100]", targetid, reason))
Let's say that's in our /kick command. If an admin does
/kick 45 spamming, the reason would be filled with 'spamming' because it was specified by the user. On the other hand, if the admin just uses
/kick 45, the reason would be filled with 'No Reason Specified' because that is the default value.
Re: Frustrating sscanf problem. -
Famalamalam - 06.08.2011
Ah ok, awesome, thanks for the explanation I understand a lot better now.
EDIT: Lol, I can finally resolve this issue in my tracker. Had it for months O_O