I have a txt file which is :
http://www.siz.co.il/my.php?i=znzwlnkn2fmq.png
and I have my structs :
typedef struct _car_s
{
char destination[50];
int priority;
struct _car_s *next;
int number_id;
}car_s, *p_car_s;
typedef struct _station_s
{
struct _station_s *waiting;
char nameofstation[50];
struct _station_s *detached;
}station_s, *p_station_s;
I would like to use your help to figure out how I can initialize my stations and cars from the file, a recommended function. Thank in advance and have a nice day.
edit :
I made a file reading function :
int read_files(char* filename, p_car_s cars, p_station_s station)
{
FILE* myFile;
char buff[1024];
myFile = fopen(filename, "r");
if(NULL == myFile)
{
printf("\n fopen() Error!!!\n");
return 0;
}
while (fgets(buff, 1024, myFile) != NULL)
{
handle_line(buff, cars, station);
}
if(fclose(myFile) == 0 )
{
buff[0]='\0';
}
}
But I cant seem to think of what to do with the function Handle_line and how to initialize the structs.. any ideas ?