Thread: can you use fstream in linux?

  1. #1
    Registered User
    Join Date
    Nov 2002

    can you use fstream in linux?

    specifically this type of file i/o:

    ifstream aFile ("blah", ios::binary)

    i don't actually have linux and i know nothing about it and can't test it, i just want to leave the option open in the future to port my program to linux.

  2. #2
    Registered User quagsire's Avatar
    Join Date
    Jun 2002
    Yes, you can use ifstream in linux. At work I had a problem using ios::binary on Unix, since all files are treated as binary. I assume you may find the same problem. Use a conditional define to test for the operating system, eg :
    #ifdef _LINUX_
    ifstream aFile ("blah");
    ifstream aFile ("blah", ios::binary);

  3. #3
    Comment your source code! Lynux-Penguin's Avatar
    Join Date
    Apr 2002
    why not just use the C defined file streams?
    Asking the right question is sometimes more important than knowing the answer.
    Please read the FAQ
    C Reference Card (A MUST!)
    Pointers and Memory
    The Essentials
    CString lib

  4. #4
    I lurk
    Join Date
    Aug 2002
    Originally posted by Lynux-Penguin
    why not just use the C defined file streams?
    ... The obvious answer: Maybe he's programming in C++.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Thinking of upgrading to linux...
    By Yarin in forum General Discussions
    Replies: 37
    Last Post: 07-24-2009, 11:40 AM
  2. Wireless Network Linux & C Testbed
    By james457 in forum Networking/Device Communication
    Replies: 3
    Last Post: 06-11-2009, 11:03 AM
  3. installing linux for the first time
    By Micko in forum Tech Board
    Replies: 9
    Last Post: 12-06-2004, 05:15 AM
  4. ARGH! fstream errors
    By OttoDestruct in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2004, 10:37 PM