I'm taking a programming module in college, where we're using Smultron and Terminal on Mac machines to edit, compile and run programs. To take an input from a file instead of from the user, our lecturer has told us to keep the cin statements in the code and to use file redirection when running the program in Terminal (e.g. ./myprog < data.txt).
This won't work on my netbook, though, because I'm using Dev-C++ under Windows 7. So instead I have been declaring ifstream variables and using these to open the files containing the data I need.
For example:
The problem is that I'm encountering a compilation error when I try to use this ifstream variable as a parameter of a function that is supposed to read data into an array.
Is there any particular way that I should be doing it?
Thanks, I know my question was a bit vague! I'm still trying to shape the code I'm working on...
A bit of digging around seems to indicate that my problem came from passing the ifstream parameter by value, instead of by reference.
One little & seems to have sorted things out, for now at least!