A little help with scanf and delimiters
#1

a little snippit of my code, i feel like im not doing this right.
Код:
if(strfind(data, "stopandhold", false) != -1)//stopandhold,dept,info,reason
{
new dept[16], info[48], reason[48];
sscanf(data,"p<,>s[16]s[48]s[48]", dept, info, reason);
//rest of code ommited
}
I am pulling csv data from a socket. But for what ever reason its not parsing all the data correctly because i suspect im not parsing the delimiters correctly. Any help here?
Reply
#2

pawn Код:
if(strfind(data, "stopandhold", false) != -1)//stopandhold,dept,info,reason
{
new dept[16], info[48], reason[48];
sscanf(data,"p<,>'stopandhold's[16]s[48]s[48]", dept, info, reason);
//rest of code ommited
}
Try this way
Reply
#3

I'll give it a shot. Thanks. I'll report back if it doesnt work.
Reply
#4

That worked like a champ sir! I appreciate the help on that, i've been wracking my brain at that for the past week and a half trying to get that stupid to thing to parse correctly. One other quick thing I have to ask

this isnt thru my sockets thru a zcmd processor
if(sscanf(params, "s[64]s[64]", str, reason))

for what ever reason if i type a string out with spaces for the var "Str" it automaticly wants to take the spaces and delmit it to the next variable. Any thoughts?
Reply
#5

using different delimiter than space would help
Reply
#6

Quote:
Originally Posted by djshadowxm81
Посмотреть сообщение
a little snippit of my code, i feel like im not doing this right.
Код:
if(strfind(data, "stopandhold", false) != -1)//stopandhold,dept,info,reason
{
new dept[16], info[48], reason[48];
sscanf(data,"p<,>s[16]s[48]s[48]", dept, info, reason);
//rest of code ommited
}
I am pulling csv data from a socket. But for what ever reason its not parsing all the data correctly because i suspect im not parsing the delimiters correctly. Any help here?
You aren't accounting for "stopandhold"

which could be;

pawn Код:
sscanf(data, "p<,>{s[chars]}s[16]s[48]s[48]", dept, info, reason);
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)