help me out.
Code:
#include <stdio.h>
#include <string.h>
#define DELIM " , \n"
#define MAXWORD 80
#define MAXLEN 20
int tokenize(char *str, char **tokens)
{
char *sep = strtok(str, DELIM);
int i=0;
while (sep != NULL)
{
strcpy(tokens[i++], sep);
sep = strtok(NULL, DELIM);
}
return i;
}
int main(void)
{
char parameters[MAXWORD][MAXLEN];
char toserver[BUFSIZ];
int ntokens = 0;
int i;
printf("Enter a string: ");
fflush(stdout);
if (fgets(toserver, sizeof toserver, stdin) != NULL)
ntokens=tokenize(toserver,parameters);
for (i = 0; i < ntokens; i++)
{
puts(parameters[i]);
}
return(0);
}
i want to store the tokens in the parameter array but i got a compilation error in line 31 saying "passing argument 2 of 'tokenize' from incompatible pointer type"
what's wrong with the code?