so what I have is the following array:
10
1 250 350 50
2 525 200 80
3 425 700 60
4 675 475 65
5 850 850 40
6 925 200 90
7 1050 575 80
8 1250 800 70
9 1375 400 60
10 1500 650 40
Each lines' value means something different, per instance
1 250 350 50
id lat long value
I want to assign each of those line values to a structure so I can play with them, but after googling and coming up with the graph theory (which is kind of similar to what I am trying to do) nothing worked... I may say that this array is being pulled from a text file, whether that is or not relevant.
struct population{
int id;
int latitude;
int longitude;
int value;
};
I can't come up with any solution, can anyone help me out or at least provide some tutorials or articles to help me clear my mind?
Here is my code:
#include <stdio.h>
#include <math.h>
#include <string.h>
#define RSIZE 20
#define CSIZE 11
struct population{
int id;
int latitude;
int longitude;
int value;
};
int main(void)
{
char line[CSIZE][RSIZE];
char fname[20];
FILE *fptr = NULL;
int i = 0;
int tot = 0;
printf("\n\n Read the file and store the lines into an array :\n");
printf("------------------------------------------------------\n");
printf(" Input the filename to be opened : ");
scanf("%s",fname);
fptr = fopen("cord.txt", "r");
while(fgets(line[i], RSIZE, fptr))
{
line[i][strlen(line[i]) - 1] = '\0';
i++;
}
tot = i;
printf("\n The contents of the file %s are : \n",fname);
for(i = 0; i < tot; ++i)
{
printf(" %s\n", line[i]);
}
printf("\n");
return 0;
}