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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.