Aquarius_Girl
Aquarius_Girl

Reputation: 22916

warning: too many arguments for format - fprintf

    pthread_t      writeToFile = pthread_self ();
    unsigned short iterate;

    for (iterate = 0; iterate < 10000; iterate++)
    {
        fprintf (fp, " %d ",  iterate,     4);
        fprintf (fp, " %lu ", writeToFile, sizeof (pthread_t));
        fprintf (fp, "\n",    writeToFile, 1);
    }

In main () fp = fopen ("xyz", "w");

Warning: warning: too many arguments for format

From here: http://www.cplusplus.com/reference/clibrary/cstdio/fprintf/

What's wrong in my code?

gcc version 4.5.0

Upvotes: 1

Views: 7872

Answers (1)

MByD
MByD

Reputation: 137322

Let's take your first fprintf: " %d ". it expects one argument (an int), but you give it two - iterate and 4.

It seems like you are adding the size of the data, but you shouldn't. It should probably be:

fprintf (fp, " %d ",  iterate);

In the other two sentences, it's not even clear what do you want to put in the file.

Upvotes: 3

Related Questions