Well, not so much difficulty, more like I am completely stumped!
I've only been programming with c++ for a few weeks, yet I have found myself in the predicament of having a small, albeit difficult assignment to complete for university pretty soon. I was wondering if anyone could help me.
Basically, we've been given a small piece of code which controls a program that opens/closes input/output .txt files;
if (argc !=3) {
cerr << "Usage: " << argv[0] << " <input filename> <output filename>" << endl;
int keypress; cin >> keypress;
return -1;
}
The program performs three tests to determine the validity of input/output files.
I had to create a .cpp and .h file to accommodate a copy() method which performs the following functions;
Test for the existence of the input file.
Open the input file
Create the output file
Read each line of text from the input file and output the line to the output file
Return true if the file has copied or return false for any other reason
This method has to be called from the main class as highlighted above.
I'm confused about a lot of things really. How to declare an instance of secondary classes in the main class, using objects as parameters. The whole #include thing for the seperate classes. And just, you know, how file streaming works in a object orientated sense. I understand the need to #include the fstream library, but how do I know which of it's functions to use. I am running visual studio.net
If anyone could help me, or point me in the right direction I would be eternally grateful!
Thanks in advance.
Edit: I don't want a solution for this, I just need some help understanding the concepts. I feel like we haven't been taught this stuff properly (well, not at all) in lectures. This seems to aid the students with a stronger programming background, unlike myself.