Question: Your friend Raphael is facing a predicament. His elementary school wanted him to submit his class roster as a .txt file, which would contain the

Your friend Raphael is facing a predicament. His elementary school wanted him to submit his class roster as a .txt file, which would contain the enrollment numbers and the names of each of the students. Initially, he had put down the data in the format of <enrollment no.> <first_name> <last_name> . However, the school, being in Japan, writes names in reverse order, ie they write the names in the format < last name> < first name>.

Raphael does not have the time to rewrite the rosters for all his students. He wants your help to change the formatting to what the school wants: <enrollment no.> <last_name> <first_name>.

Write a program in C++ that reads in a file named records.txt, which contains the records of the students in the first format, and fixes the records in the second format and churns out a file named records_fixed.txt.

Sample input (records.txt) 63628 Kaho Suzuki 63271 Akito Nakayama 83729 Hikari Ayachi

Sample output (records_fixed.txt) 63628 Suzuki Kaho 63271 Nakayama Akito 83729 Ayachi Hikari

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!