Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8855899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:14:21+00:00 2026-06-14T14:14:21+00:00

let say that i have a file ID Name Month Actual Quantity Desired Quantity

  • 0

let say that i have a file

ID  Name    Month   Actual Quantity     Desired Quantity    Cost 
2   pepsi             1                        1                3.3
3   pepsi             2                        3                5.3

how would i read that into a vector called vector<Item> items; where Item is a class that consists of those names as listed in the list. i have a set() methods for all of them but how would i read one of each values and set it for example setID() and its value and if it is empty put a value -1. What i have so far is just a basic file open

char file_name[81];
  cout<<"Enter a file to open (ex: file.txt): ";
  cin.ignore();
  flush(stdin);
  cin.getline(file_name, 81);
  ifstream input(file_name);

should i use a istringstream or what?

UPDATE:

  char file_name[81];
  cout<<"Enter a file to open (ex: file.txt): ";
  cin.ignore();
  cin.getline(file_name, 81);
  ifstream input(file_name);
  string line;
  getline(input,line);
  while (getline(input,line)){

BUT I get an error: statement cannot resolve address of overloaded function at line : ifstream input(file_name)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:14:23+00:00Added an answer on June 14, 2026 at 2:14 pm

    They way I would do is is to start writing a suitable input operator:

    std::istream& operator>> (std::istream& in, Item& item) {
        ...
    }
    

    Once this operator is in place, you can read the file using something like this:

    std::vector<Item> items;
    input.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
    std::copy(std::istream_iterator<Item>(input), std::istream_iterator<Item>(),
              std::back_inserter(items));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say that I have something like this in my web.xml file. <filter name=foo>
Let's say I have a file that's Modified in master Modified in a feature
I have a properties file, let say my-file.properties. In addition to that, I have
Let's say I have a text file that is 100 lines long. I want
Let's say I have a batch file that has padding in it, and I
For example, let's say I have a Maven build file that has dependencies located
Let's say that I have 3 fieldsets, each with 2 inputs: NAME and AGE.
Let's say that I have a file core.clj in branch master at HEAD which
Let's say that I have a file (file1.php) with a simple form with the
Let's say that I have two links. <li><a href=# id=VALUE1 class=charName>Name 1</a></li> <li><a href=#

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.