sscanf help needed..
#1

Hey,
Few weeks ago I've asked for a help getting this:
new GangNames [ 4 ] [ 20 ] =
{
"Gang Name 1",
"Gang Name 2",
"Gang Name 3",
"Gang Name 4"
};

from a file (using dini) which returns
"Gang Name 1, Gang Name 2, Gang Name 3, Gang Name 4"

Someone said, that it is possible using this:
pawn Код:
new Gangs[4][256];
sscanf(dini_Get("Gangs.info","Gangs"), "ssss", Gangs[0], Gangs[1], Gangs[2], Gangs[3]);
But this returns:
Gangs[0] = "Gang"
Gangs[1] = "Name"
Gangs[2] = "1,"
Gangs[3] = " Gang Name 2, Gang Name 3, Gang Name 4"

How can I make it to split strings where , is, but not on every space..?
Reply
#2

Using p and your splitting character. So:

pawn Код:
new Gangs[4][256];
sscanf(dini_Get("Gangs.info","Gangs"), "p,ssss", Gangs[0], Gangs[1], Gangs[2], Gangs[3]);
Reply
#3

Thanks..
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)