Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. I/O, fread.

I/O, fread.

Scheduled Pinned Locked Moved C / C++ / MFC
announcementlinuxdebuggingquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Evgeni57
    wrote on last edited by
    #1

    Hi, I have the following in my code:

    #define SIZE 16384
    while(buffer_len = fread(buffer, 1, SIZE, src))

    It works fine till the SIZE doesn't exceed 16K, but when i use 131072 for SIZE's value fread returns 0 on the first call, and it isn't eof. But while I debug it and use:

    call fread(buffer, 1, 131072, src)

    it returns 131072 and the buffer is OK. May be I'm missing some compilations flag? I'm using GNU gdb Red Hat Linux (6.3.0.0-1.143.el4rh) on Red Hat Enterprise Linux AS release 4 (Nahant Update 5) Thanks.

    S A 2 Replies Last reply
    0
    • E Evgeni57

      Hi, I have the following in my code:

      #define SIZE 16384
      while(buffer_len = fread(buffer, 1, SIZE, src))

      It works fine till the SIZE doesn't exceed 16K, but when i use 131072 for SIZE's value fread returns 0 on the first call, and it isn't eof. But while I debug it and use:

      call fread(buffer, 1, 131072, src)

      it returns 131072 and the buffer is OK. May be I'm missing some compilations flag? I'm using GNU gdb Red Hat Linux (6.3.0.0-1.143.el4rh) on Red Hat Enterprise Linux AS release 4 (Nahant Update 5) Thanks.

      S Offline
      S Offline
      sashoalm
      wrote on last edited by
      #2

      Evgeni57 wrote:

      I'm using GNU gdb Red Hat Linux (6.3.0.0-1.143.el4rh) on Red Hat Enterprise Linux AS release 4 (Nahant

      Why are you posting on the Visual C++ / MFC Forum then?

      There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal

      1 Reply Last reply
      0
      • E Evgeni57

        Hi, I have the following in my code:

        #define SIZE 16384
        while(buffer_len = fread(buffer, 1, SIZE, src))

        It works fine till the SIZE doesn't exceed 16K, but when i use 131072 for SIZE's value fread returns 0 on the first call, and it isn't eof. But while I debug it and use:

        call fread(buffer, 1, 131072, src)

        it returns 131072 and the buffer is OK. May be I'm missing some compilations flag? I'm using GNU gdb Red Hat Linux (6.3.0.0-1.143.el4rh) on Red Hat Enterprise Linux AS release 4 (Nahant Update 5) Thanks.

        A Offline
        A Offline
        anminxin
        wrote on last edited by
        #3

        fread returns the number of full items actually read, which may be less than count if an error occurs or if the end of the file is encountered before reaching count. Use the feof or ferror function to distinguish a read error from an end-of-file condition. If size or count is 0, fread returns 0 and the buffer contents are unchanged.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups