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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

708 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

16 Experts available now in Live!

Get 1:1 Help Now