C strtok() Function

Last Updated:

C strtok()

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


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; }


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

Parameter Values

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

Return Value

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

Share this Page

Meet the Author