GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Sep 23, 2014 4:23 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Converting a space separated list into an array
PostPosted: Sat Mar 13, 2010 9:07 am 
Offline
GTK+ Guru

Joined: Sun Jan 17, 2010 6:48 pm
Posts: 102
One little task that I was working on yesterday was converting a string in the form of a list space separated items, into a NULL terminated array. Ok, its simple in Tcl, but not so straight forward in C. Imagine this as:

[code=]char *str;
str = “but1 but2 but3â€


Last edited by William J Giddings on Sat Mar 13, 2010 9:48 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Converting a space separated list into an array
PostPosted: Sat Mar 13, 2010 9:47 am 
Offline
GTK+ Geek

Joined: Fri May 23, 2008 7:13 am
Posts: 73
William J Giddings wrote:
What is the most effective way of doing this?


You could use g_strsplit_set( str, " ", -1 ) for this, see:

http://library.gnome.org/devel/glib/sta ... rsplit-set


Top
 Profile  
 
 Post subject: Problem Solved
PostPosted: Sat Mar 13, 2010 5:52 pm 
Offline
GTK+ Guru

Joined: Sun Jan 17, 2010 6:48 pm
Posts: 102
Thanks for that! It was exactly what I was looking for.

WJG


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group