John McCorkle
John McCorkle

Reputation: 1

Write a line to a file line from a struct with a handful of members

typedef struct
{
char name[64];
int balance;
int gain;
}
Player;
"%s\t%d\t%d\n", p.name, p.balance, p.gain ;

I'm trying to input this into my file and I'm wondering if there is any way that I could make that into one string so it will work with fputs();

count = 0;
    while ((fgets(buffer, BUFFER_SIZE, fp)) != NULL)
    {
        count++;

        /* If current line is line to replace */
        if (count == line)
            fputs("%s\t%d\t%d\n", p.name, p.balance, p.gain,fTemp);
        else
            fputs(buffer, fTemp);
    }
``` 

Upvotes: 0

Views: 61

Answers (0)

Related Questions