1 |
|
#include <stdio.h> |
2 |
|
#include <math.h> |
3 |
|
#include <stdlib.h> |
4 |
+ |
#include <ctype.h> |
5 |
+ |
#include <string.h> |
6 |
|
#include "simError.h" |
7 |
|
#include "StringUtils.h" |
8 |
|
|
91 |
|
return 0; |
92 |
|
} |
93 |
|
|
92 |
– |
|
93 |
– |
int count_tokens(char *line, char *delimiters) { |
94 |
– |
/* PURPOSE: RETURN A COUNT OF THE NUMBER OF TOKENS ON THE LINE. */ |
95 |
– |
|
96 |
– |
char *working_line; /* WORKING COPY OF LINE. */ |
97 |
– |
int ntokens; /* NUMBER OF TOKENS FOUND IN LINE. */ |
98 |
– |
char *strtok_ptr; /* POINTER FOR STRTOK. */ |
99 |
– |
|
100 |
– |
strtok_ptr= working_line= strdup(line); |
101 |
– |
|
102 |
– |
ntokens=0; |
103 |
– |
while (strtok(strtok_ptr,delimiters)!=NULL) |
104 |
– |
{ |
105 |
– |
ntokens++; |
106 |
– |
strtok_ptr=NULL; |
107 |
– |
} |
108 |
– |
|
109 |
– |
free(working_line); |
110 |
– |
return(ntokens); |
111 |
– |
} |
112 |
– |
|
94 |
|
/** |
95 |
|
* Removes left and right spaces from a string |
96 |
|
* |