Okay, so I'm a rather green c programmer here. I need some help with header files. What goes where etc. As I think that's the reason this won't compile. I'll give you the code and hopefully you'll understand what it is I'm trying to do here. Basically I've been given an assignment to used function pointers, but no real direction other than "use function pointers for datatype functions". So this was my idea, wrap the handing of records into another struct with function pointers that do all the work of managing array operations etc.
data.h
Code:
typedef struct record
{
char name[40];
int logins;
int time;
} record;
typedef struct data
{
int size;
int count = 0;
record * arr;
void (*init) (data *,int);
init = &initFunc;
} data;
void initFunc (data *,int);
data.c
Code:
#include<stdio.h>
#include<stdlib.h>
#include "data.h"
void initFunc (data *foo, int size)
{
foo.arr = (record *) malloc(sizeof(record)*size);
foo.size = size;
}
in main.c
Code:
.
.
.
data foo;
foo.init(&foo,8);
.
.
.