Sign in to follow this  
moon_rabbits

File I/O

Recommended Posts

I know how to use fstream.h, basically. I know how to use it to manipulate text files, and that's all well and good ... but is there a way to manipulate files in a more advanced way? And on top of that, a way to create files that cannot simply be opened by the user and edited within notepad?

Share this post


Link to post
Share on other sites
Quote:
Original post by moon_rabbits
I know how to use fstream.h, basically. I know how to use it to manipulate text files, and that's all well and good ... but is there a way to manipulate files in a more advanced way? And on top of that, a way to create files that cannot simply be opened by the user and edited within notepad?

Emphasis added.

Somewhere along the way someone or something gave you the impression that fstream.h was in any way C++. It is not. It is what a few compilers used before C++ was standardized. That was a decade ago. A decade. If the person, website, or book you are using is giving information that is over a decade old then it is probably crap. I suggest you find a new resource to learn as any decent one would teach you about binary file I/O. I'd also suggest a different compiler because I really don't think any modern one would allow the use of fstream.h so that must mean you're using crap tools. Microsoft has a free version of their compiler tools called Visual Studio Express Editions, but if that isn't your cup of tea there is also code::blocks.

As for your questions, I'm not sure what you consider a more advanced way of manipulating files. Do you want to manipulate the content of the files or do you want to be able to rename, delete, move, and copy files? If you want a more difficult way for people to edit files then you should read up on binary file I/O.

Alright, so in summary:
Resources to learn: C++: A Dialog and Thinking in C++
Compilers/IDEs: Visual C++ Express Edition and Code::Blocks

Hope that helps.

edit: also, a good website for C++ information is C++ Faq-Lite. In particular they have a section on a topic called serialization that might be of interest to you in terms of doing file I/O. Read about it here

edit2: if you DID want the ability to, say, read all the files in a directory, delete files and directories, rename files, etc, then a good cross-platform library to check out is Boost's filesystem library. In fact, you should read up on boost in general.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this