What is ifstream& for?

This is a discussion on What is ifstream& for? within the C++ Programming forums, part of the General Programming Boards category; I have a classes project and one function I need inside of the class is called check(ifstream&). I am suppose ...

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    45

    What is ifstream& for?

    I have a classes project and one function I need inside of the class is called check(ifstream&). I am suppose to read from a text file and then check it against a set of data that is already written in memory. That check(ifstream&) is for the inputting of the data from the text file but I am stump on what to do with the ifstream&. What parameter do I put in that when I call it in main?

    Please give me some insights on this. Thank you.

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,594
    Open a file using ifstream and pass it to the function.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,866
    You may gain some benefit from reading through Lesson 10:File Operations to brush up on how files work with C++. Additionally, the & in this case specifies that the object will be passed by reference to the function.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ifstream
    By Wraithan in forum Tech Board
    Replies: 3
    Last Post: 09-24-2006, 01:26 AM
  2. ios::in with ifstream? Why?
    By siavoshkc in forum C++ Programming
    Replies: 4
    Last Post: 01-30-2006, 09:26 AM
  3. Regarding ifstream...
    By alvifarooq in forum C++ Programming
    Replies: 7
    Last Post: 09-24-2004, 03:12 PM
  4. little help on ifstream
    By ssjnamek in forum C++ Programming
    Replies: 1
    Last Post: 04-15-2002, 12:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21