How to write a C++ program that displays student information like:age,sex,grade,etc.. by using struct data type with file ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to write a C++ program that displays student information like:age,sex,grade,etc.. by using struct data type with file ?

by using struct data type and file

2nd Feb 2019, 5:50 AM
GJohn
3 Answers
+ 3
That's a relatively simple task.. Though working with files can somehow be tricky. What language are you referring to "C" or "C++"..
2nd Feb 2019, 6:02 AM
Mensch
Mensch - avatar
+ 1
Can any one write me the CODE in C++
2nd Feb 2019, 6:31 AM
GJohn
0
A struct data type is used to define the layout of a student record within the file. The program would need to read the data from the file into the struct, then the individual fields (variables) contained in the struct could be displayed using printf or cout statements. You would need to loop through the input and display routines until EOF. Remember to allow fillers for data in the file that you dont need to process. Failure to do that will result in the fields in each record not aligning with the fields in the struct.
2nd Feb 2019, 6:27 AM
Roger Greenlaw