Parse comma delimeted string into an array

Posted on 2008-10-16
Last Modified: 2012-08-13
I am reading the name of an application from a registry value, however I need to change the code to read multiple application names from the registry value.  The registry value will be a comme delimeted string, and I think I need to read these values into an array and then launch these application.

As I have virtually no C experience, can someone please help me with this ?
success = get_registry_value(APPLICATION, "WorkstationRole", newApplication, sizeof newApplication);


if (success)


	sprintf (WorkstationRole, "%s%s", path, newApplication);


		WorkstationRole, // cmd line

		NULL, // process sa

		NULL, // thread sa

		FALSE, // inherit handles

		0, // flags

		NULL, // env

		NULL, // cur dir




// Close the thread handle as it is not required


Open in new window

Question by:hairybarbarian
  • 2
LVL 53

Accepted Solution

Infinity08 earned 25 total points
ID: 22729011
Assuming that newApplication is a char*, you can use strtok to split it up into tokens :

char *newApplication;

char *token = strtok(newApplication, ",");

while (token) {

  /* use token here */

  token = strtok(NULL, ",");


Open in new window

LVL 45

Assisted Solution

sunnycoder earned 25 total points
ID: 22729015

appname = strtok (newApplication, "," );

while (appname)


     //create process goes here ... appname has application name

     appname = strtok (NULL, "," );


Open in new window

LVL 53

Expert Comment

ID: 22784387
May I ask what made you accept sunnycoder's response, and not mine ? It seems that we posted the same exact answer at the same time, so shared credit seems in order ... Or am I missing something ?

Author Closing Comment

ID: 31506640
Thank you.
Just what I needed, thanks again.

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
stack 22 159
How to create frequencies of a variable from SAS dataset? 10 122
xamarin c# deserialize Json containing nested object 2 81
Why is compiler in oracle server ? 9 45
Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode ( They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now