Error using fprintf to save on a .txt file.

Argument of type "cons char*" is not compatible with parameter of type "FILE*"
error on fprintf("ERROR here"...), and argument of type "int" is not compatible with "const char*" on fprintf("...",ERROR here,...)
I've used this code structure in a similar code before, what could be wrong? I checked for missing #includes, but all seems to be in order... any opinions?
(I'm using this to print on a text file some data ill need to save on a function)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>

  void Save(nodmain *header)
{
	FILE *Save = fopen("SavedGame.txt", "w");
	nodmain *auxmain = header;
	nod *aux = Inicializa();

	if (Save == NULL)
	{
		printf("ERROR");
	}
	else
	{
		while (auxmain != NULL)
		{	
			fprintf("%d,%s,%s\t", auxmain->num, auxmain->mine ? "true" : "false", auxmain->reveal ? "true" : "false");
			aux = auxmain->nextright;
			while (aux != NULL)
			{
				fprintf("%d,%s,%s\t", aux->num, aux->mine ? "true" : "false", aux->reveal ? "true" : "false");
				aux = aux->nextright;
			}
			fprintf("\n");
			auxmain = auxmain->nextdown;
		}
	}
	fclose(Save);
}


Any help would be appreciated.

Note: aux->num/auxmain->num are int type,
aux->mine/aux->reveal/auxmain->mine/auxmain->reveal are bool types.
Inicializa() is a function that initializes nod * types using malloc (no error on this function).

EDIT:
Never mind me, I'm stupid forgot to tell the fprintf where to print "fprintf(Save,"...)" XD
Last edited on
The message indicates that fprintf expects a FILE* as its first argument. You can also see this from the documentation for the function:

http://www.cplusplus.com/reference/cstdio/fprintf/

Without the pointer to the file, how would the function know which file to write to?
Last edited on
Indeed, thank you ^~^
You're welcome - glad I could help.
Topic archived. No new replies allowed.