•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 391,774 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,428 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:
Views: 1688 | Replies: 0
![]() |
•
•
Join Date: Oct 2004
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
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.
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.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
- save ram file to hard disk,how? (Graphics and Multimedia)
- R/GA Seeking Flash Dev's All Levels in NYC (Web Development Job Offers)
- A function which will transfer the data from a file to STL( vector or map) object. (C++)
- R/GA Flash Developers NYC and London (Web Development Job Offers)
- ofstream - detect if file has been deleted between open and close (C++)
- Novice asking for help in Learning C++ (C++)
- Need Help Understanding Subject in C++ (C++)
- Windows Media Player Says The File IS Corrupt But Its Not (Windows 9x / Me)
- Saving a file using C++ (C++)
Other Threads in the C++ Forum
- Previous Thread: Counting characters and dispalying numbers
- Next Thread: type casting


Linear Mode