c - Too many arguments for format [-Wformat-extra-args] -


fprintf(fptr2,"\n\n:%s",ctime(&t),"\t ","\t");  

this line works fine in dev not in ubuntu generating following error

warning: many arguments format [-wformat-extra-args]  fprintf(fptr2,"\n\n:%s",ctime(&t),"\t ","\t");                      ^ 

what should do?

fprintf takes variable number of arguments:

  • a file* output stream
  • a format string
  • one arguments each % format, preceded optional width and/or precision if these specified *.

you should have 1 argument, string %s format.

the arguments "\t" , "\t" ignored, compiler gives diagnostic presence indicates programming error.

such warnings blessing prevent many silly bugs, typos argument type mismatches. dev environment configured stay quiet these, disadvantage. fix it: add compiler options such -wall -w or -weverything.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -