Teen Programmers Unite  


Return to forum top

Binary or ASCII?

Posted by Cortez [send private reply] at August 16, 2002, 07:16:07 AM

Is there an auto function for that in C++. I mean, I have a encoding program that should open any file. But i used "w" & "r", and it doesn't work on binaries. When I use "wb" & "rb" it doesn't work on text files. Is there a way for this in VC++ 6.0?

Posted by AnyoneEB [send private reply] at August 16, 2002, 09:29:37 AM

If it's an encoding program it should use binary. What do you mean by doesn't work on text files? Does it output without spaces, give an error, or decrypt to something more confusing than the encrypted version?

Posted by DragonWolf [send private reply] at August 16, 2002, 09:46:44 AM

Cortez: There is no way to tell if the information inside the file is text or binary, unless your binary file/text file has a header or other distinctive features.

The only way to tell is to look at the file extension.

Posted by CViper [send private reply] at August 16, 2002, 02:27:55 PM

actually i always read all files in "wb" or "rb" mode; basicly it's all the same (it's just the way you treat it in your app).

EDIT: if my memory serves me right, in the win32 API you can't even specify the "type" of file you are reading. As said, it's all the same.

You must be logged in to post messages and see which you have already read.

Log on
Save for later automatic logon

Register as a new user
Copyright TPU 2002. See the Credits and About TPU for more information.