I'm confused as to how I can read a file like this: (any help/advice would be greatly appreciated! Thanks)
Params
0
1
2
3
4
1,3
Data
3,2
4,4
5,5
3,2
0,0
I've gotten this far with a program to do it:
Code:
#include <stdio.h>
int main()
{
float G, vi, B, t, duration[], burnrate[];
int mi, ve, D, S;
FILE *inFile, *outFile;
inFile = fopen("LAND2.txt", "r");
if (inFile == NULL)
{
printf("\nFailed to open the file.\n"); exit (1);
}
if (inFile != NULL)
{
printf("\nThe file LAND2.txt was opened successfully.");
}
while (fscanf(inFile, "%f", . . . )
fscanf (inFile, "Params \n"); fscanf (inFile, "%f", &G \n);
fscanf (inFile, "%f", &vi \n); fscanf (inFile, "%f", &B \n); fscanf (inFile, "%f", &t \n); fscanf (inFile, "%d", &mi \n);
fscanf (inFile, "%d", &ve \n); fscanf (inFile, "%d, %d", &D, &S);
fscanf (inFile, "Data \n");
for (i = 0; i < 5; ++i)
fscanf (inFile, "%d,%f", &duration[i], &burnrate[i] &B \n);
}
fclose (inFile);
}