sscanf strings to array problem
#1

Hello guys,

My english is not that good so I will try to explain the issue simply. I'm searching for solution about 2 hours and I can't find it.

I have string for example
Код:
"blah,blah"
but I don't know how many "blah" will this string contain. So it can be:
Код:
"blah,blah,blah"
or
Код:
"blah,blah,blah,blah,blah,blah,blah,blah,blah"
I was trying to do it this way:
Код:
	new arr[3];
	sscanf("Hello,Hi", "p<,>a<s[20]>[3]", arr);
        print(arr[1]);
but it returns
Код:
"ello,Hi"
Simply: I want to split the string after every "," and save the words as arr[0], arr[1].

Thank you for help.
Reply
#2

See: http://forum.sa-mp.com/showpost.php?...20&postcount=3
Reply
#3

EDIT: Wait, I was doing it wrong!

Something like this.

On the other hand, you can just be shameless, predict the amount of strings you'll have, declare an array of that size (indStrings[10][128]) - use sscanf's optional parameters ('S') and that's it..
Reply
#4

Quote:
Originally Posted by ******
Посмотреть сообщение
I tried to do it that way but it returns now:
Код:
Hello
ello
I think I'm not understanding it well.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)