/* File Name : splitok.c Course Number : ISYS 290-04 Student Name : Jason Gradziel Student Number : 826-135-535 Professors Name : Brian Perry Class Name : Wednesday 9:55 - 12:35 Lab Title : Decscription : Splits Tokens, count the number of words in a string. Inputs text string, the delimier, maximum lenght of string, words. Outputs a number of count which is the number of words in the string. */ #define MAXLEN 1024 #include int split_tokens ( char *text, char *delims, int max, char *words[]) { static char temp[MAXLEN]; int count = 0; char *p; strcpy (temp, text); p = strtok(temp, delims); words[count] = p; count++; while ( (p != NULL) && (count <= max) ) /*words[count+1] != NULL) && (count <= max) )*/ { p = strtok (NULL, delims); words [count] = p; count++; } count = count - 1; return count; }