write to file .. pointer to structure array
I am trying to learn how to write from a pointer to a structure array to a file ..
this what I have so far.
this is a learning exercise for me later I want to write a structure holding different variable types and write a file.
my overall objective is to have a file of the screen size .. image size and location of my mandelbrot set program so I have a record of where I have been.
any help appreciated thanks in advance al.
Code:
#include<stdio.h>
//prototyping my structure
struct foo{
int array[5];
};
int main(){
//creating a foo structure bar and assigning a pointer to it
struct foo bar;
struct foo *p;
p = &bar;
//creating a file pointer
FILE *fp;
//counter
int c;
//giving values to array elements in structure
for(c = 0; c < 5; c++){
p->array[c] = c;
}
//pinting out values .. checking
for(c = 0; c < 5; c++){
printf(" c = %i i = %i\n",c,p->array[c]);
}
//opening a file so I can write values to it
fp = fopen("foobar.txt","wb");
/*
no idea what to put in here
*/
//closing file
fclose(fp);
return;
}