Question
Problem 2 (Save and Get Info) : C++ language. Write a program that asks for the user's name, phone number, and address. The program then
Problem 2(Save and Get Info) : C++ language. Write a program that asks for the user's name, phone number, and address. The program then saves all information in a data file (each information in one line) namedlist.txt. Finally, the program reads the information from the file and displays it on the screenin the following format: Name: User's Name Phone Number: User's Phone Number Address: User's Street Address User's City, State, and Zip Code
This is what I have:
#include #include #include using namespace std; int main() { fstream file; file.open("list.txt", ios::out); string name, phone, address, street, city, state, zip;
// User Input cout > name; cout > phone; cout > street; cout > state; cout > city; cout > zip;
file file file file file file
file.open("list.txt", ios::in);
getline(file, name); getline(file, phone); getline(file, street); getline(file, city); getline(file, state); getline(file, zip);
cout cout cout
system("pause"); return 0; } Icantfigure out how to be ableto togettwo worditems like first name and last name without it skipping othercinfunctions.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started