open or fopen?

This is a discussion on open or fopen? within the C Programming forums, part of the General Programming Boards category; ....

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    4

    Post open or fopen?

    .
    Last edited by Tibo; 03-28-2003 at 02:46 AM.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    fopen is the standard C function that returns a FILE *, open is system dependent and typically takes some form of file descriptor. So you should use fopen if you plan on using functions that require a FILE *.

    -Prelude
    My best code is written with the delete key.

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >Functions taking FILE* arguments are not an argument for preferring fopen( ) over open( ), because the POSIX core APIs
    >require support for fdopen( ), which associates a FILE object with a file descriptor.
    I'll rephrase then: If you want to program as portably as possible, then fopen should be preferred as it is an ISO C standard function while open is not.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fopen can't open .exe?
    By fanoliv in forum C Programming
    Replies: 11
    Last Post: 04-05-2011, 04:24 PM
  2. open, fopen ?
    By Matrim in forum C Programming
    Replies: 2
    Last Post: 02-01-2005, 09:45 AM
  3. fopen() and open()
    By Encrypted in forum C Programming
    Replies: 8
    Last Post: 02-09-2003, 04:57 PM
  4. fopen vs open
    By rotis23 in forum Linux Programming
    Replies: 5
    Last Post: 12-10-2002, 02:30 PM
  5. Ghost in the CD Drive
    By Natase in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 10-12-2001, 06:38 PM

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