Showing results for 
Search instead for 
Did you mean: 

reading from file into array of structures

Go to solution

I would like to read from file into  array of structures. The file can be organized as one structure per line:




My intent is to initialize some integer constants depending on a frequency band given by first two elements in structure as follows:

I'm not sure how to initialize the structure from the file.


typedef struct {
    double lowFreq;
    double highFreq;
    int doubler;
    int PreN;
    int mult;
    int N;
    int cpGain;
} Band[numBands];
    for (i = 0; i = numBands; i++) {
        if ((inFreq >= band[i].lowFreq) & (inFreq <= band[i].highFreq))
                doubler = band.doubler;
                PreN = band.PreN;
                mult = band.mult;
                N = band.N;
                cpGain = band.cpGain;


0 Kudos
Message 1 of 3
Accepted by topic author the_emc_guy

Given the file structure you have reported, I see no way of reading it other that using either standard C functions (fopen, fgets, fclose) or their equivalents in the CVI Formatting and I/O Library (OpenFile, ReadLine, CloseFile). The help file for the functions include links to some example programs that may help you to design your own code.

Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
If I have helped you, why not giving me a kudos?
Message 2 of 3

That's what I'll do.


0 Kudos
Message 3 of 3