0

G'day!

It's a pretty aesthetic warning flag, but I don't like it.

holiday.c:39:37: warning: format specifies type 'char *' but the argument has
      type 'FILE *' (aka 'struct __sFILE *') [-Wformat]
                printf("Error opening file %s\n", fp);
                                       ~~     ^~

This is a copy from the gcc output. Is there a % something for printing a file name, where fp is declared as

FILE *fp;

and opened as:

fp=fopen(argv[1],"r");

from a command line input.

I had trouble finding any literature about it through, but not overly thorough google search.

Thanks! :)

James Adams
  • 678
  • 4
  • 11
  • 21
  • The "*% something*" is called "*Converison Specifier*". For your reference: http://man7.org/linux/man-pages/man3/printf.3.html – alk Oct 12 '14 at 10:57
  • I appreciate that, alk! Always useful to be able to express myself using the correct terminology :) – James Adams Oct 12 '14 at 11:03
  • 1
    This is a major programming error that's pretty likely to crash the program when it runs, it's far from "pretty aesthetic warning flag". – unwind Oct 12 '14 at 11:07

0 Answers0