returns a 1 when the strings are the same. Never mind then.
strncmp(line, "ENDL", 4)
Instead of printing out the structure every time I scan it, I want to store then in an array of structures. So I'd pass the pointer to the array to a function that will read in all the individual structures. I don't really get how it is explained here:
That's from Prelude's FAQ again.
struct Node *make_node ( void )
struct Node new_node = malloc ( sizeof *new_node );
/* Error check and set a default state */
I did it like it makes sense to me:
Right now it exits the loop right away, again.
int i, j, nExpected, nActual=0;
struct EDFLine *Sec;
Sec = calloc(nExpected, sizeof (struct EDFLine));
ReadSection(inp, Sec, nExpected, &nActual);
int ReadSection(FILE * inp, struct EDFLine Sec, int nExpected, int*nActual)
while ( fgets(line, sizeof line, inp) != NULL )
if ( strncmp(line, "ENDL", 4) == 0 )
if (strncmp(line, "END", 3) != 0)
if ( sscanf(line, "%s %d %d %d %d %d", Sec[i].Param, &Sec[i].Label,
&Sec[i].SFactor, &Sec[i].SigBits, &Sec[i].Bit30, &Sec[i].Bit31) == 6)
if (*nActual == nExpected)
Oh, and you guys told me numerously before not to typecast the calloc and never worked for me before. It kept giving me an incompatibility error, but now it worked.....