I have a text file and I want  to read it in C++.  variables to use: fname, lname , Id nr, Gender and all third line which is an address .  Note: *** The result in your program should be written to a new file. So you need to open 2 files in your program, one for reading and one for writing. The file is :    Tommy James  23456731667 Streetname 45 , 154 23 Georgia  John Andersson 3456723464 Streetname 12 , 231 32 Las Vegas  Kim Larsson  3456312653 Streetnamn 15, 231 56 Florida If we Said the 8th digit in ID number is showing the Gender of the person. By %2== 0 it's Male  The output should be:  Lname Fname [F]  address   Is there possible to create a program in C++  with the previously output. lname , fname [F] Adress  Without have a problem with Las Vegas word. I have a hard time to figure how I can do the third line in the file. They read to word Las and then the compiler shows terminate called after throwing an instance of ' std::invalid_ argument ' what (): stoi aborted  so I figured that the problem I have in one line the city is two wo

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter7: File Handling And Applications
Section: Chapter Questions
Problem 15RQ
icon
Related questions
Topic Video
Question

I have a text file and I want  to read it in C++. 
variables to use: fname, lname , Id nr, Gender and all third line which is an address . 

Note: ***

The result in your program should be written to a new file. So you need to open 2 files in your program, one for reading and one for writing.


The file is : 

 

Tommy James 

23456731667

Streetname 45 , 154 23 Georgia 


John Andersson

3456723464

Streetname 12 , 231 32 Las Vegas 

Kim Larsson 

3456312653

Streetnamn 15, 231 56 Florida

If we Said the 8th digit in ID number is showing the Gender of the person. By %2== 0 it's Male 

The output should be: 

Lname Fname [F] 

address

 

Is there possible to create a program in C++  with the previously output.

lname , fname [F]
Adress 

Without have a problem with Las Vegas word.

I have a hard time to figure how I can do the third line in the file. They read to word Las and then the compiler shows

terminate called after throwing an instance of ' std::invalid_ argument '

what (): stoi

aborted 

so I figured that the problem I have in one line the city is two word.

Expert Solution
steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage