- Get link
- X
- Other Apps
oh, problems run vast , numerous on one. idea 1 take text file, information of 3 cars on 3 lines, , put 3 structures. (i have included text file - , no, information doesn't make sense, that's instructor wrote , wants use.)
program doesn't run - it's not complete - it's have far. know want have done: want take said text file, , read in, 1 line @ time, information 3 structures, , print 3 of them out screen. problem here we've gone beyond book, take @ next class' material since we're done, , don't have information build off of.
reading material may beneficial me? words of wisdom or slaps head?
(like said, posted i've come far. it's more random notes show @ least have vs don't.)
in cars.txt file: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 = 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 = 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); } }
attached files:
i have routine either takes pointer single struct, or returns single struct. should take line of input parsed. in function can loop, reading file , calling function each line. take array of structs. there can function takes array , element count display values.
-lee
Forums Macs Mac Programming
- iPhone
- Mac OS & System Software
- iPad
- Apple Watch
- Notebooks
- iTunes
- Apple ID
- iCloud
- Desktop Computers
- Apple Music
- Professional Applications
- iPod
- iWork
- Apple TV
- iLife
- Wireless
- Get link
- X
- Other Apps
Comments
Post a Comment