dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: fread() bug in Visual C runtime library, what is the Visual C++ version?

  1. #1
    Join Date
    Jan 2003
    Posts
    375

    fread() bug in Visual C runtime library, what is the Visual C++ version?

    I read following forum post about the problem that fread() function can't read large files:
    http://stackoverflow.com/questions/7...-read-by-fread

    I am now writing a program that need large file support on VS2008, I use fopen, fread and fwrite to process files, some of the files maybe about 4G. If there is a bug in fread() function in Visual C runtime library, what is the version of the Visual C++? Thank you!

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,560

    Re: fread() bug in Visual C runtime library, what is the Visual C++ version?

    Since you are asking in the Visual C++ Programming forum, I can suggest you using either Win32 API (CreateFile, ReadFile, WriteFile,...) or MFC CFile class methods.
    Victor Nijegorodov

  3. #3
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: fread() bug in Visual C runtime library, what is the Visual C++ version?

    You can use CFile which is based on basic windows file access.

    don't use CStdioFile, which is based around FILE and fread() (and it's family of functions).

  4. #4
    Join Date
    Jan 2003
    Posts
    375

    Re: fread() bug in Visual C runtime library, what is the Visual C++ version?

    Thank you very much for your replies! I am re-writing the code using CreateFile, ReadFile, WriteFile, and CloseHandle. and commented out the fopen, fread and fwrite.

    But I still want to know is there really a bug in fread in Visual C++ that can't process large file. Thanks!

    Following are similar questions I searched online :
    https://social.msdn.microsoft.com/Fo...rum=vclanguage

    http://bytes.com/topic/c/answers/825...ails-files-4gb
    Last edited by forester; October 22nd, 2015 at 05:13 AM.

  5. #5
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: fread() bug in Visual C runtime library, what is the Visual C++ version?

    it's not a bug, it's simply how things are. fread returns a size_t and takes size_t parameters, which on win32 has the range of an unsigned int.
    can't fix this without making the code non-standard C.

    if you compile as Win64, it'll work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)