#include #include int main() { char str[] = "apple,orange,banana,grape"; // The string to be tokenized char *token; // Pointer to store the extracted token // Get the first token // The first call to strtok takes the string to be tokenized and the delimiters token = strtok(str, ","); // Loop through the string to extract all subsequent tokens // Subsequent calls to strtok use NULL as the first argument to continue from the last position while (token != NULL) { printf("%s\n", token); token = strtok(NULL, ","); } return 0; }