/* This program illustrates reading and parsing command-line input based on a : character. */ #include #include int main() { const char* colon = ":"; char buffer[21]; char* token; /* Copy a set of paths into the buffer. */ strcpy(buffer, "Path 1:Path 2:Path 3"); /* Print the paths. */ printf("\nThese are the paths: %s\n", buffer); /* Print the paths broken into colon-delimited tokens. */ printf("\nThese are the paths parsed into colon-delimited tokens (one per line): \n\n"); token = strtok(buffer, colon); while (token != NULL) { printf("%s\n", token); token = strtok(NULL, colon); } return 0; }