warning: format not a string literal and no format arguments

后端 未结 3 1000
小蘑菇
小蘑菇 2020-11-27 04:27

I want to remove the warning that i get on this line of the code,

FILE *fil;
char *imp;
(...)
fprintf(fil,imp);

the thing is when i do thi

3条回答
  •  清歌不尽
    2020-11-27 04:41

    While technically there's nothing wrong with calling a printf-like function with a string, it is still bad practice because the string may contain format tokens like %s. If imp is %s test for example, bad things will happen.

    If you just want to print the imp without formatting, you should use fputs(imp, fil) (note the reversed arguments).

提交回复
热议问题