V
V
VadimBrazevich2018-05-01 19:09:48
C++ / C#
VadimBrazevich, 2018-05-01 19:09:48

How to write a structure to a file and read it back?

It is necessary to write the structure to a file, and then use it again.

struct Lesson {

  int number;
  string day;
  string lessonName;
  string groupName;
  string teacher;
  string classroom;
};

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Bogdan, 2018-05-01
@4elovek37

1. Use the standard ofstream and ifstream
2. Write term by term, for strings write first size_t length, then the string itself
3. Read in the same order as written, after reading number, consider the next size_t as the size of day, and so on.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question