sscanf2 error
#1

Код:
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...
Reply
#2

Add a simple, fake variable?
Reply
#3

pawn Код:
if(!sscanf(string1, "s[256]", string2))
Reply
#4

Quote:
Originally Posted by AK47317
Посмотреть сообщение
pawn Код:
if(!sscanf(string1, "s[256]", string2))
Well that works, but not when i compare string to "TEXT".
Reply
#5

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.
Reply
#6

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?
Reply
#7

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.
Reply
#8

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.
Reply
#9

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.
Reply
#10

You are just a hard head ARE YOU? sscanf is NOT for comparing strings!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)