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
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.