can you use fstream in linux?

This is a discussion on can you use fstream in linux? within the Linux Programming forums, part of the Platform Specific Boards category; specifically this type of file i/o: ifstream aFile ("blah", ios::binary) i don't actually have linux and i know nothing about ...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    21

    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
    Posts
    60
    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 :
    Code:
    #ifdef _LINUX_
    ifstream aFile ("blah");
    #else
    ifstream aFile ("blah", ios::binary);
    #endif

  3. #3
    Comment your source code! Lynux-Penguin's Avatar
    Join Date
    Apr 2002
    Posts
    533
    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
    Posts
    1,361
    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, 12:40 PM
  2. Wireless Network Linux & C Testbed
    By james457 in forum Networking/Device Communication
    Replies: 3
    Last Post: 06-11-2009, 12:03 PM
  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, 11:37 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21