fstream vs FILE

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • solarrobor

    fstream vs FILE

    I am currently porting a program from C to C++. The program needs to
    read the file "/proc/bus/usb/devices".
    I am able to open and read from the file using FILE but not when I use
    fstream.

    Why does it work with FILE and not fstream?
    What is the solution to making it work using fstream?

    I am using GCC 4.2.3 on Fedora 8
  • Victor Bazarov

    #2
    Re: fstream vs FILE

    solarrobor wrote:
    I am currently porting a program from C to C++. The program needs to
    read the file "/proc/bus/usb/devices".
    I am able to open and read from the file using FILE but not when I use
    fstream.
    >
    Why does it work with FILE and not fstream?
    Because in your fstream use there is a logical error on line 42.
    What is the solution to making it work using fstream?
    The solution is usually to fix the problem. Since you didn't tell
    us what the problem actually is, how can we help you fix it?

    Another possible solution is not to do anything, just keep using
    FILE pointers and you should be OK.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask


    Comment

    • Christopher

      #3
      Re: fstream vs FILE

      On Mar 7, 12:04 pm, "Victor Bazarov" <v.Abaza...@com Acast.netwrote:
      solarrobor wrote:
      I am currently porting a program from C to C++. The program needs to
      read the file "/proc/bus/usb/devices".
      I am able to open and read from the file using FILE but not when I use
      fstream.
      >
      Why does it work with FILE and not fstream?
      >
      Because in your fstream use there is a logical error on line 42.
      >
      What is the solution to making it work using fstream?
      >
      The solution is usually to fix the problem. Since you didn't tell
      us what the problem actually is, how can we help you fix it?
      >
      Another possible solution is not to do anything, just keep using
      FILE pointers and you should be OK.
      >
      V
      --
      Please remove capital 'A's when replying by e-mail
      I do not respond to top-posted replies, please don't ask

      I have to disagree, Victor. My crystal ball is bigger and shinier and
      it says it is line 63.

      Comment

      • Victor Bazarov

        #4
        Re: fstream vs FILE

        Christopher wrote:
        On Mar 7, 12:04 pm, "Victor Bazarov" <v.Abaza...@com Acast.netwrote:
        >solarrobor wrote:
        >>I am currently porting a program from C to C++. The program needs to
        >>read the file "/proc/bus/usb/devices".
        >>I am able to open and read from the file using FILE but not when I
        >>use fstream.
        >>
        >>Why does it work with FILE and not fstream?
        >>
        >Because in your fstream use there is a logical error on line 42.
        >[..courtesy snip of overquoted material..]
        >
        I have to disagree, Victor. My crystal ball is bigger and shinier and
        it says it is line 63.
        Apparently your ball is bigger by exactly 50%... <g>

        V
        --
        Please remove capital 'A's when replying by e-mail
        I do not respond to top-posted replies, please don't ask


        Comment

        • Paavo Helde

          #5
          Re: fstream vs FILE

          solarrobor <franzaklein@ya hoo.co.ukwrote in news:e886828b-d88b-4eee-8f71-
          fefc6c10c3cd@n7 7g2000hse.googl egroups.com:
          I am currently porting a program from C to C++. The program needs to
          read the file "/proc/bus/usb/devices".
          I am able to open and read from the file using FILE but not when I use
          fstream.
          Porting C to C++ involves providing function declarations in header files
          and some more obscure changes. The FILE* interface is perfectly OK in C++,
          so it seems you are probably wasting your employer's money ;-)

          NHTH (not hoping this helps... )
          Paavo

          Comment

          Working...