Array of structs C++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Array of structs C++

How do you write a function that asks a user for the input file name(txt file), and then read all data from that file and the data have to be stored into an array of structs.

6th Feb 2019, 7:43 AM
lakas
4 Answers
+ 2
I think than the better way to resolve your problem is understand what you cannot coding.. Where you have a problem? You know how read from console input? How read a file?
6th Feb 2019, 7:59 AM
KrOW
KrOW - avatar
+ 2
Start with reading here http://www.cplusplus.com/doc/tutorial/files/ It explain how work with files in c++. Insert data inside an array of struct, involve in knowing how many struct you need (eg this info would be inside the file to read) then read all data following a logic used for create the file.
6th Feb 2019, 8:14 AM
KrOW
KrOW - avatar
+ 2
I suggest to read the tutorial linked on my previous comment so you will find more easy solve your problem and you will learn something
6th Feb 2019, 8:17 AM
KrOW
KrOW - avatar
0
how do you read a file and store it into the array of structs?
6th Feb 2019, 8:07 AM
lakas