Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I parse a token from a string in C?

Tags:

c

string

tokenize

How do i parse tokens from an input string. For example:

char *aString = "Hello world".

I want the output to be:

"Hello" "world"

like image 752
Progress Programmer Avatar asked Nov 28 '22 21:11

Progress Programmer


2 Answers

You are going to want to use strtok - here is a good example.

like image 79
Andrew Hare Avatar answered Dec 01 '22 11:12

Andrew Hare


Take a look at strtok, part of the standard library.

like image 42
Todd Gamblin Avatar answered Dec 01 '22 11:12

Todd Gamblin