+ 1

🙏🏻Help: Pointers, classes, Structs, arrays, file I/o, functions

How to ask user to input file name, then read all the data from that file? And how to structure a file where the first line is the shoe store info, followed by five shoe types? The data have to be stored into arrays of class type objects. Thanks a bunch!

20th Sep 2018, 1:21 AM
lakas
1 Odpowiedź
+ 1
to get the filename, use something like cin >> filename to read the file data you can use ifstream (google cpp ifstream) as for structuring the file, you can try to create a class like so class shoeinfo { string storename; string address; void readinfo( ifstream f ) void writeinfo( ofstream f ) } class shoetype { etc etc } when you write the file call the appropriate writeinfo routine, ifstream f = ...etc var_shoeinfo->writeinfo(f) for (i=0; i < sizeof(array_shoetype); i++) array_shoetype[i].writeinfo(f) f->close()
23rd Sep 2018, 7:47 AM
Nestor