Question: String Tokens The function char * strtok ( char * source, const char * delimiters) breaks the parameter source into tokens by finding group of
String Tokens
The function char * strtok ( char * source, const char * delimiters) breaks the parameter source into tokens by finding group of characters separated by any of the delimiting characters .
#include
#include
#define COMMA ",."
int main(int argc, char const *argv[]) {
char date[] = "Jan 12, 1842. May 13, 2018";
char *token = strtok(date, COMMA);
while(token != NULL) {
printf("%s ", token);
token = strtok(NULL, COMMA);
}
}
The output of this code will be :
Jan 12
1842
May 13
2018
Write a simple program in C that accepts a file path from the user and prints each part of the file path, including the file extension, on separate lines. You have to use strtok in this task.use mostly strings dont use malloc or alloc or struct keyword.
Input 1
C:\Users\Alice\Documents\test.c
Output 2
C:
Users
Alice
Documents
test
c
Input 2
U:\Books\book1.pdf
Output 2
U:
Books
book1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
