sscanf2 question
#1

hey guys just wanna check my understanding of the code here:

basically this:

pawn Код:
format(filestring,sizeof(filestring), "1,2.4,5.3,6.9,7.2,6,7,hello");
sscanf(filestring, "p<,>iffffiis", int1,float1,float2,float3,float4,int2,int3,string1);
that should split the full string into its component parts using the , as a separator and put them into the variables specified right?

just checking my understanding which admittedly may be hugely flawed lol
Reply
#2

Yes, you're right:

All specifiers

For quick reference, here is a list of ALL the specifiers and their use:

Код:
Format					Use
L(true/false)				Optional logical truthity
l					Logical truthity
K<callback>(any format number)	Optional custom operator
k<callback>				Custom operator
B(binary)				Optional binary number
b					Binary number
N(any format number)			Optional number
n					Number
C(character)				Optional character
c					Character
I(integer)				Optional integer
i					Integer
D(integer)				Optional integer
d					Integer
H(hex value)				Optional hex number
h					Hex number
O(octal value)				Optional octal value
o					Octal value
F(float)				Optional floating point number
f					Floating point number
G(float/INFINITY/-INFINITY/NAN/NAN_E)	Optional float with IEEE definitions
g					Float with IEEE definitions
{					Open quiet section
}					Close quiet section
P<delimiters>				Multiple delimiters change
p<delimiter>				Delimiter change
Z(string)[length]			Invalid optional string
z(string)[length]			Deprecated optional string
S(string)[length]			Optional string
s[length]				String
U(any format number)			Optional user (bot/player)
u					User (bot/player)
Q(any format number)			Optional bot (bot)
q					Bot (bot)
R(any format number)			Optional player (player)
r					Player (player)
A<type>(default)[length]		Optional array of given type
a<type>[length]				Array of given type
E<specification>(default)		Optional enumeration of given layout
e<specification>			Enumeration of given layout
'string'				Search string
%					Deprecated optional specifier prefix
?					Local options specifier
Reply
#3

Thanks! I was more worried there would be a limit on identifiers i could use - i have a string I'm pulling from a file and it has about 32 variables stored in it split by ",". I have not had a chance to test the code but looks like i should be ok and it's a hell of alot faster than using the string split function i had already.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)