C strtok() Function

Last Updated:

C strtok()

The strtok() breaks string into a series of tokens using the given delimiter.

Example

C Compiler
#include <string.h> #include <stdio.h> int main() { char str[] = "www.wikimass.com"; char s[] = "."; char *token; token = strtok(str, s); while(token != NULL) { printf("%s\n", token); token = strtok(NULL, s); } return 0; }

Syntax

char *strtok(char *str, const char *delim)

Parameter Values

ValueTypeExplanation
str Required Specifies a string
delim Required Specifies a delimiter to break the given string.

Return Value

ValueExplanation
Address Returns a pointer to the first token found in the string.
NULL If no token found.

Share this Page

Meet the Author