fstream vs fopen

This is a discussion on fstream vs fopen within the C++ Programming forums, part of the General Programming Boards category; I am starting to write a parser for a ini file for a friend as a learning experience. They told ...

  1. #1
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094

    fstream vs fopen

    I am starting to write a parser for a ini file for a friend as a learning experience. They told me that for file IO that streaming is not as good as using the fopen/fclose or win32 api file IO. I was curious why this was, they would never really supply a decent answer and it seemed like they said that because of preference, but I wanted to check with a resource of more experience programmers.

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    As an old-time C programmer I personally prefer fopen() and associated functions because I'm very accustom to them. I find fstream c++ class to be ackward except in the most simplest instances. New programming students will not have these prejudices, so if you feel competent with fstream, by all means use it. fstream can be a little slower than FILE and associated functions and can bloat the program a little more. But on modern desktop computers that is not a very relevant argument. It will, however, make a big difference in time-critical and embedded programs where space is a premium.

  3. #3
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    I am more comfortable with fstream right now, but I am learning fopen. Win32 API makes my head explode, but I am working on that also. Thanks for the reply.

  4. #4
    Registered User
    Join Date
    Aug 2003
    Posts
    470
    I am starting to write a parser for a ini file for a friend as a learning experience. They told me that for file IO that streaming is not as good as using the fopen/fclose or win32 api file IO. I was curious why this was, they would never really supply a decent answer and it seemed like they said that because of preference, but I wanted to check with a resource of more experience programmers.
    You could use win32 functions that parse .ini files. (Better for programming efficiency) But if you do write your own parser, C++ streams ought achieve similar results as C io streams.But some implementations might require you to setup the streams specially to achieve the best speed. Read your C++ iostreams library documentation.

  5. #5
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    where would I find that documentation. I use Bloodshed Dev-C++ with Mingw Version 4

  6. #6
    Registered User
    Join Date
    Aug 2003
    Posts
    470
    where would I find that documentation. I use Bloodshed Dev-C++ with Mingw Version 4
    I think this link covers what you need to know. Looks like you don't need to setup anything with dev C++ but Stroustrup's book covers this too I think.
    http://www-aig.jpl.nasa.gov/public/h..._11.html#SEC11

  7. #7
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    I just noticed the last time my compiler was updated was 2000. I don't want to use the newer beta version (i had a lot of issues trying to use that) is there a more up to date compiler with a IDE? I also want to stay away from VC++ till I learn Win32 and can understand more.

  8. #8
    Registered User Jaqui's Avatar
    Join Date
    Feb 2005
    Posts
    416
    Quote Originally Posted by Wraithan
    I just noticed the last time my compiler was updated was 2000. I don't want to use the newer beta version (i had a lot of issues trying to use that) is there a more up to date compiler with a IDE?
    with devc++ and mingw you are using gcc's g++
    here is where you can get latest stable gcc. I would follow the links to the mingw downloads and download the latest stable mingw version of gcc.

    then point devc++ at the newer version of the compiler.
    Quote Originally Posted by Jeff Henager
    If the average user can put a CD in and boot the system and follow the prompts, he can install and use Linux. If he can't do that simple task, he doesn't need to be around technology.

  9. #9
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    you can get newest version 4.9.9.2 from www.bloodshed.net

  10. #10
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    That is a beta version, and I have had a ton of trouble trying to use it.

  11. #11
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    scroll down the page here and you will find non-beta version 4. I'm using the version 5 beta and haven't had any problems -- yet.

    Also click Help-->About and you will find more links to updates. I don't know when the mingw compiler itself has been updated.
    Last edited by Ancient Dragon; 10-16-2005 at 06:33 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Fstream. I/O
    By kevinawad in forum C++ Programming
    Replies: 2
    Last Post: 07-07-2008, 10:19 AM
  2. help with stat() and fopen()
    By movl0x1 in forum C Programming
    Replies: 6
    Last Post: 07-25-2007, 06:28 AM
  3. ARGH! fstream errors
    By OttoDestruct in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2004, 11:37 PM
  4. Are fstream and ofstream incompatible?
    By johnnyd in forum C++ Programming
    Replies: 5
    Last Post: 03-19-2003, 12:21 PM
  5. Problems with fstreams.
    By mosdef in forum C++ Programming
    Replies: 7
    Last Post: 06-19-2002, 04:36 PM

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