binary files reference needed!

This is a discussion on binary files reference needed! within the C Programming forums, part of the General Programming Boards category; hey folks, i need a good reference(s) to binary files. if anyone knows of one or some, could you please ...

  1. #1
    Unregistered
    Guest

    Exclamation binary files reference needed!

    hey folks,

    i need a good reference(s) to binary files. if anyone knows of one or some, could you please let me know.

    tnx,
    ben

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    What kind of reference information do you need?

    -Prelude
    My best code is written with the delete key.

  3. #3
    Unregistered
    Guest

    just examples

    um, i just need to see a bunch of examples
    just want to get a quick look at the way things are done in terms of programming with binary files

    i hope this has made a bit more clear.


    tnx,
    ben

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    Okay, fiddle around with this for starters
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    struct Record
    {
      char name[80];
    } static sRec[3];
    
    int main ( void )
    {
      FILE *fp;
      strcpy ( sRec[0].name, "Julienne Walker" );
      strcpy ( sRec[1].name, "Danny Raxter" );
      strcpy ( sRec[2].name, "Amir Salyen" );
      if ( ( fp = fopen ( "tst.txt", "wb" ) ) != NULL ) {
        (void)fwrite ( sRec, sizeof ( struct Record ), (size_t)3, fp );
        (void)fclose ( fp );
      }
      if ( ( fp = fopen ( "tst.txt", "rb" ) ) != NULL ) {
        (void)fread ( sRec, sizeof ( struct Record ), (size_t)1, fp );
        (void)fclose ( fp );
      }
      return EXIT_SUCCESS;
    }
    My best code is written with the delete key.

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Why are you casting the return value of your functions to void? Just curious, as there is no logical reason to do this.

    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >Why are you casting the return value of your functions to void?
    Because I like to see Lint say 'no warnings'

    -Prelude
    My best code is written with the delete key.

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, 09:18 PM
  2. how to copy binary files using Unix API's
    By rohan_ak1 in forum C Programming
    Replies: 25
    Last Post: 05-07-2008, 10:12 AM
  3. Merge Binary Files
    By chinook86 in forum C Programming
    Replies: 7
    Last Post: 01-21-2008, 02:19 PM
  4. Textbox
    By maxorator in forum Windows Programming
    Replies: 20
    Last Post: 09-25-2005, 11:04 AM
  5. Decimal to binary conversion help needed
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 02-06-2002, 01:03 PM

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