Answers for "Parsing using strtok"

C
0

Parsing using strtok

// A C/C++ program for splitting a string
// using strtok()
#include <stdio.h>
#include <string.h>
 
int main()
{
    char str[] = "Geeks-for-Geeks";
 
    // Returns first token
    char* token = strtok(str, "-");
 
    // Keep printing tokens while one of the
    // delimiters present in str[].
    while (token != NULL) {
        printf("%sn", token);
        token = strtok(NULL, "-");
    }
 
    return 0;
}
Posted by: Guest on January-09-2022

Code answers related to "C"

Browse Popular Code Answers by Language