fread: Bus error

This is a discussion on fread: Bus error within the Linux Programming forums, part of the Platform Specific Boards category; Hi I am trying to copy the contents of a file into memory. The size of file is about 5-6 ...

  1. #1
    Just kidding.... fnoyan's Avatar
    Join Date
    Jun 2003
    Location
    Still in the egg
    Posts
    269

    fread: Bus error

    Hi
    I am trying to copy the contents of a file into memory. The size of file is about 5-6 Kb (Wouwww!!!). So, as you guess "fread" gives me bus error. I tried the same code with a smaller file (about 200-250 bytes) and it works. So, the rest of the code is OK.
    Is there anything that I can do or do I have to write my own function in order to read from file by spliting the data in it into smaller sizes.

    PS: I am using FreeBSD 5.1 and GCC.

    Thanks....
    Fehmi Noyan ISI

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Post your code (or relevant snippet of it) so we can help you determine where the problem is.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Obsessed with C chrismiceli's Avatar
    Join Date
    Jan 2003
    Posts
    501
    Have you looked into mmap?
    Help populate a c/c++ help irc channel
    server: irc://irc.efnet.net
    channel: #c

  4. #4
    Just kidding.... fnoyan's Avatar
    Join Date
    Jun 2003
    Location
    Still in the egg
    Posts
    269
    Hi
    first of all thanks guys....
    Hammer : I think there is no problem with the code. As I wrote earlier the code works with a 200-250 byte file. My problem is the size of file!
    chrismiceli : I will try. But unfotunatelly it is not possible now. Keep in touch, may be it will not work!

  5. #5
    Registered User
    Join Date
    Aug 2004
    Posts
    34
    why not try and copy small chunks at a time?
    ~flood

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  4. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 03:49 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 12:10 AM

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