defined in string.h

char * strtok ( char * str, const char * delimiters );
Splits string to tokens

The strtok() function parses a string into a sequence of tokens. On the first call to strtok() the string to be parsed should be specified in str. In each subsequent call that should parse the same string, str should be NULL.

The delim argument specifies a set of characters that delimit the tokens in the parsed string. The caller may specify different strings in delim in successive calls that parse the same string.

Each call to strtok() returns a pointer to a null-terminated string containing the next token. This string does not include the delimiting character. If no more tokens are found, strtok() returns NULL.

A sequence of two or more contiguous delimiter characters in the parsed string is considered to be a single delimiter. Delimiter characters at the start or end of the string are ignored. Put another way: the tokens returned by strtok() are always non-empty strings.


str : string to split

delimiters : string containing the delimiter characters, these can be different from one call to another.


If token is found, a pointer to the token, or a null pointer if not found.

#include <stdio.h>
#include <string.h>

int main ( int argc, char* argv[])
	char str_data[] = "String to split";
	char * str_token = NULL;
	printf ("splitt string \"%s\" into tokens :\n", str_data);
	str_token = strtok( str_data," ");
	while ( str_token)
		printf ("%s\n", str_token);
		str_token = strtok( NULL, " ");


Split string into tokens

posted on 2019-03-17 20:41:48 - C Programming Language Tutorials


zalloc is a third party library

posted on 2018-12-12 20:46:30 - C Programming Language Tutorials


posted on 2017-12-29 22:52:47 - C Programming Language Tutorials

Prompt Examples

ChatGPT Prompt Examples

posted on 2023-06-21 22:37:19 - ChatGPT Tutorials

Use Cases

Chat GPT Key Use Cases

posted on 2023-06-21 21:03:17 - ChatGPT Tutorials

Prompt Frameworks

Prompt Frameworks

posted on 2023-06-21 19:33:06 - ChatGPT Tutorials