0

Hi,
I have this function to tokenize an input string:

int tokenize(char input[], char* tokens[], char delimiter[])
{...}

There are invocations of the function with different size of array. For instance,

char tokens[2][100];
tokenize(input, tokens, " ");

char tokens1[3][10];
tokenize(tokens[0], tokens1, ":");

as you can see the token holder array passed to tokenize can be of different dimension so I am trying to define the tokenize function so that second argument has a array dimension unspecified. But whatever I do it does not work:

int tokenize(char input[], char** tokens, char delimiter[]);

int tokenize(char input[], char* tokens[], char delimiter[]);

int tokenize(char input[], char (*tokens)[], char delimiter[]);
of which I find the last one the most amusing:
10281.c:79: error: cannot convert ‘char (*)[100]’ to ‘char (*)[]’ for argument ‘2’ to ‘int tokenize(char*, char (*)[], const char*)’

I thought the first one should work as the 2dimensional array should be considered as pointer to pointer.

I don't know what can I do *court* my compiler to do his job.

Please help.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Dave Sinkula
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.