Question

I am having trouble trying to output my file Lab13.txt. It will say that everything is...

I am having trouble trying to output my file Lab13.txt. It will say that everything is correct but won't output what is in the file. Please Help

Write a program that will input data from the file Lab13.txtPreview the documentView in a new window(downloadable file);

a name, telephone number, and email address.

Store the data in a simple local array to the main module, then sort the array by the names. You should have several functions that pass data by reference.
Hint: make your array large enough to hold 100 entries
and you may require research on a sort routine.  

Output the array to the monitor.

Take a screen shot of the monitor and paste into a word document.

Submit both your word document and your .cpp file for grading.

This is what I have right now

#include "stdafx.h"
#include<iostream>
#include<string>
#include<fstream>
using namespace std;

void inputUser(string &namesAddress);
void outputUser(string & namesAddress);

int main()
{
   string namesAddress;
   inputUser(namesAddress);
   outputUser(namesAddress);
   system("pause");
return 0;
}

void inputUser(string & namesAddress)
{
   string line;
   int count = 100;
   string fileName;
   cout << "Enter the File name you wish to open: ";
   getline(cin, fileName);
   fstream file(fileName.c_str());
   if (file.fail())
   {
       cout << "could not open file: "
           << (fileName) << endl;
   }


   //add a positive resurance of what you wrote to the user
   else
   {
       cout << "Everything you wrote is correct."
           << endl;
   }

   while ((count>0) && getline(file, line))
   {
       cout << line << endl;
       count--;
   }
  
   //ifstream inputFile;
   //inputFile.open("Lab13.txt");
//   file.close();
  
}

void outputUser(string & namesAddress)
{
  
   cout << namesAddress;
}

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
I am having trouble trying to output my file Lab13.txt. It will say that everything is...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • C++ problem. hi heys, i am trying to remove beginning and the end whitespace in one...

    C++ problem. hi heys, i am trying to remove beginning and the end whitespace in one file, and output the result to another file. But i am confused about how to remove whitespace. i need to make a function to do it. It should use string, anyone can help me ? here is my code. #include <iostream> #include <iomanip> #include <cstdlib> #include <fstream> using namespace std; void IsFileName(string filename); int main(int argc, char const *argv[]) { string inputfileName = argv[1];...

  • My code doesn't output correctly using a .txt file. How do I clean this up so...

    My code doesn't output correctly using a .txt file. How do I clean this up so it posts correctly? ----------------------------------------------- CODE ---------------------------------------------- #include <iostream> #include <string> #include <fstream> #include <iomanip> #include <fstream> using namespace std; struct Customer {    int accountNumber;    string customerFullName;    string customerEmail;    double accountBalance; }; void sortDesc(Customer* customerArray, int size); void print(Customer customerArray[], int size); void print(Customer customerArray[], int size) {    cout << fixed << setprecision(2);    for (int i = 0; i...

  • In c++ please How do I get my printVector function to actually print the vector out?...

    In c++ please How do I get my printVector function to actually print the vector out? I was able to fill the vector with the text file of names, but I can't get it to print it out. Please help #include <iostream> #include <string> #include <fstream> #include <algorithm> #include <vector> using namespace std; void openifile(string filename, ifstream &ifile){    ifile.open(filename.c_str(), ios::in);    if (!ifile){ cerr<<"Error opening input file " << filename << "... Exiting Program."<<endl; exit(1); }    } void...

  • Hi! 1. I need some help with sorting string in a text file. My goal is...

    Hi! 1. I need some help with sorting string in a text file. My goal is to 1 shift left strings for string.length time. I was able to do that successfully. However, I am also trying to sort, using insertion sort , the resulting shifts. I store all shifts in a vector (or is it better to use an array?!) , and try to sort them that way, but my output is just the shifted strings but not sorted. Can...

  • My C++ program is not compiling. Please explain how you fixed with detailed inline comments. I am using Visual Studio 2017. It's a character count program that keeps and displays a count of all th...

    My C++ program is not compiling. Please explain how you fixed with detailed inline comments. I am using Visual Studio 2017. It's a character count program that keeps and displays a count of all the upper, lower case and digits in a .txt file. The requirement is to use classes to implement it. -----------------------------------------------------------------HEADER FILE - Text.h--------------------------------------------------------------------------------------------- /* Header file contains only the class declarations and method prototypes. Comple class definitions will be in the class file.*/ #ifndef TEXT_H #define...

  • Hey, so i am trying to have my program read a text file using a structure...

    Hey, so i am trying to have my program read a text file using a structure but i also want to be able to modify the results(I kinda have this part but it could be better). I cant seem to get it to read the file(all the values come up as 0 and i'm not sure why because in my other program where it wrote to the txt file the values are on the txt file) i copied and pasted...

  • I am having problems with reading a file into an array. This is my code. This...

    I am having problems with reading a file into an array. This is my code. This is what I get when I run my program. But this is my text file I am reading. I tried everything and it seems to be reading in the last digit of the file. I want to read in their names line by line into an array and ultimatly also read in the scores line by line. 1 E/7 Programming Assignment 6.cpp Defines the...

  • First create the two text file given below. Then complete the main that is given. There...

    First create the two text file given below. Then complete the main that is given. There are comments to help you. An output is also given You can assume that the file has numbers in it Create this text file: data.txt (remember blank line at end) Mickey 90 Minnie 85 Goofy 70 Pluto 75 Daisy 63 Donald 80 Create this text file: data0.txt (remember blank line at end) PeterPan 18 Wendy 32 Michael 28 John 21 Nana 12 Main #include...

  • Can someone help me put the string removee the return to an outfile and fix?? prompt: CS 575 LabEx14: no e’s Let the user specify an input file and an output file (text files). Read the input file and...

    Can someone help me put the string removee the return to an outfile and fix?? prompt: CS 575 LabEx14: no e’s Let the user specify an input file and an output file (text files). Read the input file and write the output file; the output file should be the same as the input file, except that it has no e’s. For example, if the input file had the line. Streets meet in the deep. Then the output file would have...

  • (Coding done in c++, Virtual Studio) Having a problem with the line trying to compare the...

    (Coding done in c++, Virtual Studio) Having a problem with the line trying to compare the date of birth.            **fall.sort(compare_DOB); //Here lies your error** #include <fstream> #include <iostream> #include <string> #include <list> #include <cctype> using namespace std; const char THIS_TERM[] = "fall.txt"; const string HEADER = "\nWhat do you want to do ?\n\n" "\t. Add a new friend name and DOB ? \n" "\t. Edit/Erase a friend record ? \n" "\t. Sort a Friend's record ? \n"...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT