create pointer to pass to printf family

Hello, I wanted to pass an array to printf but I get this when compiling

fprintf(stderr, "%s: Error: Option '%s' has already been given "\
               "and may not be given again.
", my_name, &option );

Format argument 2 to fprintf (%s) expects char * gets char [200] *: &option

Is there another way to do this?

What programming language is this about?
I suppose C, but that’s hard to guess by just looking at that line and error message.

And what datatype is “option”?

If it is “char option[200]” (i.e. a string with 200 characters), you get the pointer to the string by just using “option”.

&option would be the address of the pointer in this case… :wink:

PS: the trailing ‘’ in your first line of printf is not necessary.
C doesn’t care about newlines (it’s treated like a space).
A statement is not terminated by a newline, but by ‘;’ anyway.

Appending lines with ‘’ is only necessary for preprocessor commands, which have to be one line.

Well it works, I’m suprized, I thought that you had to pass *printf a pointer, still, the beginning of the array is where the pointer would point to anyway.
I know that a trailing \ is not needed, but I think it makes the code look better.

Yes, to print a string you have to pass a pointer to the first character of the string, i.e. char *.
But in C an array is nothing else than a pointer to the first element, i.e. char x] is the same as char *x.
You took the address of that apparently, so in fact you passed a pointer to the pointer to the first character, i.e. char *x] or char **x.

I know that a trailing \ is not needed, but I think it makes the code look better.

Ok, I just thought I’d mention it.