I am attempting to write an array of the first N primes to a txt file in rows of 5 entries each, with 10 spaces between each entry. The relevant code is as follows:
#include<stdio.h>
#include<math.h>
#define N 1000
...
void writePrimesToFile(int p[N], char filename[80])
{
int i;
FILE *fp = fopen(filename, "w");
for(i = 0; i<=N-1; i++)
{
for(i = 0; i<5; i++)
{
fprintf(filename, "%10%i", p[i]);
}
printf("/n");
fclose(fp);
}
printf("Writing array of primes to file.\n");
}
The compiler throws the following error:
primes.c:40:4: warning: passing argument 1 of ‘fprintf’ from incompatible pointer type [enabled by default]
fprintf(filename, "%10%i", p[i]);
^
In file included from /usr/include/stdio.h:29:0,
from primes.c:1:
/usr/include/stdio.h:169:5: note: expected ‘struct FILE *’ but argument is of type ‘char *’
int _EXFUN(fprintf, (FILE *, const char *, ...)
^
Numerous Google searches have not been fruitful. Any help would be much appreciated.
expected ‘struct FILE *’ but argument is of type ‘char *’