LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-31-2007, 12:30 AM   #1
amit_pansuria
Member
 
Registered: Sep 2006
Posts: 73

Rep: Reputation: 15
how to open file in binary mode


helo,
i m using fedora 6 .
i m writing my application using c,c++
how can i open any file in binary format
Regards,
Amit
 
Old 07-31-2007, 12:33 AM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
In C++, you use "ios::binary" as the second argument to your ifstream/ofstream constructor:

ifstream in("foo", ios::binary);
ofstream out("foo", ios::binary);

Not sure about C.
 
Old 07-31-2007, 02:49 AM   #3
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
files as a binary concept belongs to those inferior O.S's.
there is no binary and ASCII under unix like systems.
 
Old 07-31-2007, 03:15 AM   #4
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Eh? Why not?
 
Old 07-31-2007, 03:31 AM   #5
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
well, in DOS you have ascii and binary, so in ascii if you write a
file it will translate a "\n" to a "\r\n"

while in unix a "\n" is a "\n", a file is a file is a file.


like the ASCII and binary mode for ftp, if you mix it up on DOS it
messes the file up but in unix it doesn't care.

another wondeful legacy from mr Gates' crap programming, as well as enabling the internet to fill up with viruses, spam and botnets
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to open /proc file in RW mode in user mode? cranium2004 Programming 3 03-06-2005 03:03 AM
Wget - forcing binary mode? Darklegion Linux - Software 1 08-25-2004 11:24 PM
Blender binary file fails to open adhara Linux - Software 1 12-09-2003 07:35 PM
perl NET::FTP binary mode lackluster Programming 5 07-18-2002 06:30 PM
File upload in binary mode via HTTP saravanan1979 Programming 0 04-05-2002 01:48 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration