-
December 10th, 2010, 09:55 AM
#1
Does random files are always in binary format and not in text format?
Does random files are always in binary format and not in text format?
-
December 10th, 2010, 10:30 AM
#2
Re: Does random files are always in binary format and not in text format?
I'm sorry, I don't understand the question, in C and C++ you choose whether or not to write in binary or text.
-
December 10th, 2010, 06:57 PM
#3
Re: Does random files are always in binary format and not in text format?
In theory, no. But because text-mode files usually have variable line lengths, there is no easy way to determine the position of any particular record in the file. It is possible to use padding to achieve a consistent record length to simplify random-access to records in a pure text file, but in fact I have never actually seen that being done in slightly more than three decades of programming and it would be pretty risky to manipulate files like this using an ordinary text editor. (Of course, binary files can contain fields consisting of readable text and that is not uncommon.)
HTH
Last edited by Eri523; December 10th, 2010 at 07:00 PM.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
December 10th, 2010, 07:39 PM
#4
Re: Does random files are always in binary format and not in text format?
Originally Posted by forumuser11@gmail.com
Does random files are always in binary format and not in text format?
Wow.
-
December 13th, 2010, 03:01 PM
#5
Re: Does random files are always in binary format and not in text format?
Originally Posted by Eri523
In theory, no. But because text-mode files usually have variable line lengths, there is no easy way to determine the position of any particular record in the file. It is possible to use padding to achieve a consistent record length to simplify random-access to records in a pure text file, but in fact I have never actually seen that being done in slightly more than three decades of programming and it would be pretty risky to manipulate files like this using an ordinary text editor. (Of course, binary files can contain fields consisting of readable text and that is not uncommon.)
HTH
Well, technically, there's no difference between "text" and "binary" files. All files are binary. On windows platforms the difference come in, in the "layer" that reads and writes the data. That being, a carriage return/linefeed is read as a linefeed (or something to that effect). On *NIX boxes, "text" mode and "binary" mode mean exactly the same thing.
Viggy
-
December 13th, 2010, 03:10 PM
#6
Re: Does random files are always in binary format and not in text format?
In C, all functions that deal with io default to using text. Haven't looked at the fstreams, but I would assume they do too.
But like MrViggy said, they behave the same way on almost all computers.
-
December 13th, 2010, 05:03 PM
#7
Re: Does random files are always in binary format and not in text format?
In addition to what's already said, in text mode a Ctrl-Z marks the end of the file.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|