Jump to content
  • Advertisement
Sign in to follow this  
Yamian

File IO: Where am I in the file

This topic is 4736 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been ptogramming for some time and suprisingly never had to deal with File IO becasue I just used SDL and all it needed was a file name. Well anyway, I'm trying to encrypt my files now so I need to learn. I found this tutorial http://www.cprogramming.com/tutorial/cfileio.html and liked it more than the others I found except I had one little confusion thing. Where the heck are you in the file? I know it says you can pass how many bytes of the file you want to read, but what if a want to, say, skip the first couple bytes of the file? Can someone please forwarsd me to a more in depth tutorial?

Share this post


Link to post
Share on other sites
Advertisement
C : ftell(fp)
C++ : istream::tellg() or ostream::tellp()

In binary mode, you can interpret that as a number of bytes.
In text mode, you cannot interpret it at all, only pass it to fseek/seekg/seekp.

Share this post


Link to post
Share on other sites
so wait, u didn't give much explination. do tellp and tellq tell you where you are in the file or do they set where you are in the file?

Share this post


Link to post
Share on other sites
Quote:
Original post by Yamian
so wait, u didn't give much explination. do tellp and tellq tell you where you are in the file or do they set where you are in the file?


As the function names suggest, they tell you. You would use ostream::seekg to go to a position, or fseek in C.

For more detailed information on the methods, visit your local online web resource

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!