M
Martin
Hi,
I have been trying to construct my own library of commonly used C
functions and have got a bit stuck and wonder if anyone could give me
any pointers?
I have set up a generic read function...
void read_file_float(FILE **fp, float **array, int size, char **argv)
{
if (fread(*array, sizeof (float), size, *fp) != size) {
fprintf(stderr, "Error reading in file: %s\n", *argv);
exit(1);
}
return;
}
which I call using the following in my code for example
FILE *fp;
float *array (which I allocate);
int numrows = something;
int numcols = something
read_file_float(&fp, &array, numrows * numcols, argv);
This works fine.
The problem comes when I do something similar but instead use fseek -
so in this instance i only want to read part of the file into the
array e.g. array[counter]
Now my call to the function would be
read_file_float(&fp, &array[some_counter]), 1, argv);
But I don't know how to declare this correctly.
Any thoughts?
Thanks in advance
I have been trying to construct my own library of commonly used C
functions and have got a bit stuck and wonder if anyone could give me
any pointers?
I have set up a generic read function...
void read_file_float(FILE **fp, float **array, int size, char **argv)
{
if (fread(*array, sizeof (float), size, *fp) != size) {
fprintf(stderr, "Error reading in file: %s\n", *argv);
exit(1);
}
return;
}
which I call using the following in my code for example
FILE *fp;
float *array (which I allocate);
int numrows = something;
int numcols = something
read_file_float(&fp, &array, numrows * numcols, argv);
This works fine.
The problem comes when I do something similar but instead use fseek -
so in this instance i only want to read part of the file into the
array e.g. array[counter]
Now my call to the function would be
read_file_float(&fp, &array[some_counter]), 1, argv);
But I don't know how to declare this correctly.
Any thoughts?
Thanks in advance