C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 03-12-2002, 07:27 PM   #1
Unregistered
Guest
 
Posts: n/a
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
  Reply With Quote
Old 03-12-2002, 07:31 PM   #2
Code Goddess
 
Prelude's Avatar
 
Join Date: Sep 2001
Posts: 9,664
What kind of reference information do you need?

-Prelude
__________________
My best code is written with the delete key.
Prelude is offline   Reply With Quote
Old 03-12-2002, 07:49 PM   #3
Unregistered
Guest
 
Posts: n/a
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
  Reply With Quote
Old 03-12-2002, 07:51 PM   #4
Code Goddess
 
Prelude's Avatar
 
Join Date: Sep 2001
Posts: 9,664
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.
Prelude is offline   Reply With Quote
Old 03-12-2002, 08:30 PM   #5
+++ OK NO CARRIER
 
quzah's Avatar
 
Join Date: Oct 2001
Posts: 10,640
Why are you casting the return value of your functions to void? Just curious, as there is no logical reason to do this.

Quzah.
__________________
Hundreds of thousands of dipshits can't be wrong.


Are you up for the suck?
quzah is offline   Reply With Quote
Old 03-12-2002, 09:13 PM   #6
Code Goddess
 
Prelude's Avatar
 
Join Date: Sep 2001
Posts: 9,664
>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.
Prelude is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting an error with OpenGL: collect2: ld returned 1 exit status Lorgon Jortle C++ Programming 6 05-08-2009 08:18 PM
how to copy binary files using Unix API's rohan_ak1 C Programming 25 05-07-2008 09:12 AM
Merge Binary Files chinook86 C Programming 7 01-21-2008 02:19 PM
Textbox maxorator Windows Programming 20 09-25-2005 10:04 AM
Decimal to binary conversion help needed Unregistered C Programming 6 02-06-2002 01:03 PM


All times are GMT -6. The time now is 11:32 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

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