This code is supposed to run through a loop and write data to a file descriptor.
When I run this program I get a "segmentation fault" and I'm not sure why. I'm guessing it has to do with format().
void format(int n, char *d, FILE *f);
int i, n=0;
for(i=0; i<=5; i++)
format(n, d, f);
fprintf(f, "stack #1, 15");
void format(int n, char *d, FILE *f)
snprintf(fm, 16, "%s.%d.txt", d, n);
f = fopen(fm, "w");
How can I use format() to correctly write data to a fd?