Oh, the problems run vast and numerous on this one. The idea for this one is to take a text file, with information of 3 cars on 3 lines, and put it into 3 like structures. (I have also included that text file - and no, information doesn't make sense, but that's what the instructor wrote and wants us to use.)
This program doesn't run - it's not complete - it's what I have this far. I know what I want to have done: I want to take said text file, and read in, one line at a time, the information for the 3 structures, and then print the 3 of them out to the screen. The problem here is we've gone beyond the book, to take a look at the next class' material since we're just about done, and we don't have much information to build off of.
Any reading material that may be beneficial to me? Any words of wisdom or slaps to the head?
(Like I said, I only posted what I've come up with so far. It's more like random notes to show you at least what I have vs what I don't.)
In the cars.txt file:
This program doesn't run - it's not complete - it's what I have this far. I know what I want to have done: I want to take said text file, and read in, one line at a time, the information for the 3 structures, and then print the 3 of them out to the screen. The problem here is we've gone beyond the book, to take a look at the next class' material since we're just about done, and we don't have much information to build off of.
Any reading material that may be beneficial to me? Any words of wisdom or slaps to the head?
(Like I said, I only posted what I've come up with so far. It's more like random notes to show you at least what I have vs what I don't.)
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
typedef struct auto_t{
char make[15]; char model[30];
int mmon; int mday; int myear;
int pmon; int pday; int pyear;
float fuelcap; float fuellevel;
float odometer;
} vehicles[3];
//xxxxxxxxxxxxxxxxxxxxxxxxxMAINxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
int main(void)
{
//int readCar(vehicles*, FILE*);
//vehicles V;
//int i = 0;
//int itemsread;
//FILE *cfPtr;
void getinfo(auto_t*);
void printit(auto_t);
auto_t a1, a2, a3;
}
return 0;
}
//xxxxxxxxxxxxxxxxxxxxxxFUNCTIONxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
void getinfo (auto_t *Pup)
{
int n;
int i = 0;
char c;
int size;
if((cfPtr = fopen("cars.txt", "r")) == NULL)
printf ("ERROR: NOT FOUND.\n");
else
{
while(!feof(cfPtr))
{
itemsread = readCar (&V, cfPtr);
printf ("%s %s\n", V[i].make, V[i].model);
printf ("%i %i %i\n", V[i].mmon, V[i].mday, V[i].myear);
printf ("%i %i %i\n", V[i].pmon, V[i].pday, V[i].pyear);
printf ("%f %f\n", V[i].fuelcap, V[i].fuellevel);
printf ("%f\n", V[i].odometer);
}
fclose(cfPtr);
}
}
In the cars.txt file:
Mercury Sable 99942 1 18 2001 5 30 1991 16 12.5
Mazda Navajo 123961 2 20 1993 6 15 1993 19.3 16.7
Toyota Camry 8223 6 13 2009 4 12 2009 15 8.9