Rockbox Technical Forums

Rockbox Development => Starting Development and Compiling => Topic started by: Zeltzer on February 14, 2010, 02:37:13 PM

Title: API: anything to split string into an array exists?
Post by: Zeltzer on February 14, 2010, 02:37:13 PM
Hello, I need to split a st|ri|ng into an array, are there any custom RB routines that I don't need to rewrite? I honestly looked today through the code, but haven't found yet.

Just don't want to add some unnecessary code.
Title: Re: API: anything to split string into an array exists?
Post by: funman on February 14, 2010, 04:05:34 PM
if it isn't in the standard C library it's unlikely
Title: Re: API: anything to split string into an array exists?
Post by: Zeltzer on February 14, 2010, 05:14:56 PM
What I'm looking for is a ready Rockbox function that does that, using ANSI C, of course.
I just don't want to add a new one if it already exists and I simply cannot see it.

Something that reads substring|delimiter|substring sequentially.
Title: Re: API: anything to split string into an array exists?
Post by: Domonoky on February 14, 2010, 05:34:10 PM

There is no function to split it directly to a array in C or rockboxs plugin api.
But you can easily do this yourself with the strtok_r funktion to seperate the string into tokens and then put those token in a array yourself.
(look at normal C strtok documentation on how to use that).