Hello,
I put on an earlier post about using linked lists for data, but I've seen the error of my ways (and the limited RAM which I tried to employ). What I would like to do now is read and write to a file (hopefully one) to store frequency data. What I'd like my program to do is load a 3d array of data and write that data to a file when a datum is outside the specifications. Then, when another datum is accessed/generated within a certain range, if that is already present in the file to load a chunk of data to the array, write the file with the chunk currently in there, and update the new chunk. Here's some pseudocode to illustrate what I'm talking about:
Sample datum, in format (A,B,Theta,Frequency): 0 200 180 1
Code:
make a 3d array of doubles
while(there are still more sample points)\
{
-Generate specific sample point
-if(sample point is within the array's boundaries)
add 1 to the appropriate spot
continue
-else
if( the current array has already been stored)
update the data in the file
else
insert the array data into the file
flush the array and change it's boundary conditions
load data in the region of the new point to the array (if it exists)
Store the Sample point
}
When there are no more sample points, read the file and divide each frequency number by the total number of points.
I don't know too many file commands. Before, I had been using simple things like fopen() fclose() fscanf() and fprintf().
I want to make sure that I don't overwrite useful data while at the same time making sure that my file doesn't have repeats or anything so that I don't have unnecessarily large files to read/write.
I was hoping to organize the file somewhat like this
#A
$B1
A\tB1\tTheta\tfrequency
A\tB1\tTheta\tfrequency
...
$B2
A\tB2\tTheta\tfrequency
...
#A2
Any Suggestions on what commands I should use, etc. Would be greatly appreciated. Thanks