Syntax of strtok()

char *strtok(char *str, const char *delims);

Parameters

  • str: It is the pointer to the string to be tokenized.
  • delims: It is a string containing all delimiters.

Return Value

  • It returns the pointer to the first token encountered in the string.
  • It returns NULL if there are no more tokens found.

How to Split a String by a Delimiter in C?

Splitting a string by a delimiter is a common task in programming. In C, strings are arrays of characters, and there are several ways to split them based on a delimiter. In this article, we will explore different methods to split a string by a delimiter in C.

Similar Reads

Splitting Strings in C

The strtok() method splits str[] according to given delimiters and returns the next token. It needs to be called in a loop to get all tokens. It returns NULL when there are no more tokens....

Syntax of strtok()

char *strtok(char *str, const char *delims);...

C program for splitting a string

C Program to demonstrate how to split a string using strtok()....