how to catch a parameter that is of the wrong type

Hi there,

Here is the prototype for the myConcat function which takes a variable number of arguments. I am to create a file that contains a definition of the myConcat function.

    char* myConcat\(int n, ... \)

When the function is called, the first argument should be an integer > 0.
The other arguments should all be of type char* and are expected to point to '\0'-terminated sequences of chars. The first argument indicates how many "string" arguments are passed. myConcat should return the concatenation of these strings.

Note that the file must not contain a main() function. The only names visible outside the file (when it is compiled together with other .c files) should be "myConcat".

How do I make sure that the proper arguments have been passed to myConcate? For example myConcate(3, "Hello", "There", "!") would be correct, but myConcate(3, "Hello", 5.0, "There") should generate some kind of error because 5.0 is not a pointer to char.

Also, is there anything I have to do to make sure that the only names visible outside the file should be "myConcat"?

Thanks to anyone whose able to give me some kind of hint!
Magda

C doesn't provide a way to check the datatype of an argument, which is why the compiler does it. variable argument lists are an exception to this.

It is the responsibility of the calling function to make sure the arguments are correct - in this case.

For example, printf() is in the same boat that your function is. It will print garbage or even segfault in this case:

double z=13.1;
printf("%s\n",z);

Note that printf cannot check to see if "z" is a character array. You code has the same issue.
[/code]