Thread: file i/o

  1. #1
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916

    file i/o

    I'm think I am having some problems with this, and I'm wondering if it's because I am trying to do something that can't be done. What it is is that I have saved data in a binary file, which I wrote by using fwrite like this...

    fwrite(&anarrayofstructs, sizeof(thestuct), numberofelementsinthearray, filepointer);

    I am trying to read it in the same way, except with fread...is this not possible, or is my error somewhere else? Or is there maybe something that I don't know?

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,263
    try this

    // set the packing alignment to 1 byte
    #pragma pack(1)

    //your file structs go here

    // set the packing alignment to default
    #pragma pack(0)
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  3. 2 questions surrounding an I/O file
    By Guti14 in forum C Programming
    Replies: 2
    Last Post: 08-30-2004, 11:21 PM
  4. File I/O problems!!! Help!!!
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 05-17-2002, 08:09 PM
  5. advice on file i/o
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 11-29-2001, 05:56 AM