C Programming Language |
malloc |
calloc |
memset |
memcpy |
memory |
strcpy |
string |
strtok |
isalnum |
cctype |
errno |
cfenv |
clock |
difftime |
mktime |
ctime |
fprintf |
fscanf |
printf |
scanf |
stdio |
math |
defined in string.h
char * strtok ( char * str, const char * delimiters );
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, " ");
}
return EXIT_SUCCESS;
}
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