sscanf2 error - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: sscanf2 error (
/showthread.php?tid=243274)
sscanf2 error -
Mike Garber - 22.03.2011
Код:
sscanf warning: Format specifier does not match parameter count.
I get this error when my server is running, and i use;
pawn Код:
if(!sscanf(string,string2))
The script works and that code works but It's annoying and spamming my console and server_log.
Is there anyway to make it stop?
I read it was a bug and i should ignore it but It's spamming it.. Yes I know i can use strcmp but sscanf is better...
Re: sscanf2 error -
Zh3r0 - 22.03.2011
Add a simple, fake variable?
Re: sscanf2 error -
AK47317 - 22.03.2011
pawn Код:
if(!sscanf(string1, "s[256]", string2))
Re: sscanf2 error -
Mike Garber - 22.03.2011
Quote:
Originally Posted by AK47317
pawn Код:
if(!sscanf(string1, "s[256]", string2))
|
Well that works, but not when i compare string to "TEXT".
Re: sscanf2 error -
JaTochNietDan - 22.03.2011
Why do you use sscanf for string comparisons? sscanf is for un-formatting strings, not for comparing them, you should use strcmp (string compare) for the comparison of strings.
Re: sscanf2 error -
Mike Garber - 22.03.2011
Quote:
Originally Posted by JaTochNietDan
Why do you use sscanf for string comparisons? sscanf is for un-formatting strings, not for comparing them, you should use strcmp (string compare) for the comparison of strings.
|
Because it works and Isn't It faster?
Re: sscanf2 error -
JaTochNietDan - 22.03.2011
Quote:
Originally Posted by Mike Garber
Because it works and Isn't It faster?
|
Well it's not actually doing what you think it's doing. It's not returning false if the strings match, it's just returning false if sscanf finds all of the specified formats in the string, for example:
pawn Код:
sscanf("hello 21", "sd", string, integer);
That's getting the information from hello 21 string, splitting it, and storing it in string/integer accordingly. It returns false there because it was a success.
pawn Код:
sscanf("hello", "sd", string, integer);
That will return true, because it failed at getting the integer part of the string, it couldn't find it in the string.
If you want to compare two strings to see if they match, you still use strcmp.
Re: sscanf2 error -
Mike Garber - 22.03.2011
Quote:
Originally Posted by JaTochNietDan
Well it's not actually doing what you think it's doing. It's not returning false if the strings match, it's just returning false if sscanf finds all of the specified formats in the string, for example:
pawn Код:
sscanf("hello 21", "sd", string, integer);
That's getting the information from hello 21 string, splitting it, and storing it in string/integer accordingly. It returns false there because it was a success.
pawn Код:
sscanf("hello", "sd", string, integer);
That will return true, because it failed at getting the integer part of the string, it couldn't find it in the string.
|
Pretty much the same thing, yet not exactly, as strcmp. Obviously, as It works perfectly fine.
Re: sscanf2 error -
JaTochNietDan - 22.03.2011
Quote:
Originally Posted by Mike Garber
Pretty much the same thing, yet not exactly, as strcmp. Obviously, as It works perfectly fine.
|
How is it the same thing? sscanf is not for comparing strings, sscanf is for un-formatting them. strcmp is for comparing strings.
Re: sscanf2 error -
Zh3r0 - 22.03.2011
You are just a hard head ARE YOU? sscanf is NOT for comparing strings!