I am creating the system that outputs all the registered student in one of my textfile e.g
123 Michael
412 Voker
512 Karl
143 Riki
I need to use their ID to search for the student Means i need to read this register student file.
The system will only ask for the ID. e.g
Type ID num: 123
OUTPUT:
Hello Michael your ID number is 123.
Hang on, here I have compiled a working example covering all your posted questions.
The below solution though is written in a very idiomatic
c++
way (the solution sports a usage ofstream_iterators
when writing/reading files for a non-trivial container data type (i.e.std::map
):Sample output:
Probably your are looking for a struct or class. Make a Student class I would say.
Give a go through the link [1] to understand how you can read or write a Student object from or to a file respectively.
[1] https://www.geeksforgeeks.org/readwrite-class-objects-fromto-file-c/