[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

RE: binary file format under linux



what kind of data does it need?

C program (this is an untested quickie):

/* creates a binary file with MAXDATA integers */
/* includes go here */
#include <stdio.h>
#include <stdlib.h>

/* define global variables */
#define MAXDATA 2000	/* maximum number of data points */

/* function prototypes go here */
unsigned int f( void );

int main (int argc, char *argv[])
{
	FILE		*outfile;
	char		*filename;
	unsigned int	data;
	int		i;

	/* get filename from command line */
	strcpy(filename, argv[1]);
	strcat(filename, ".bin");

	outfile = fopen(filename, "wb");

	for(i=0 ; i<MAXDATA ; i++)
	{
		/* get data */
		data = f();

		/* print the data to a file - each data point is followed by
a CR */
		fprintf( outfile, "%ui\n", data);
	}

	fclose(outfile);
}

unsigned int f( void )
{
	/* put your code to get integers here */
}

> -----Original Message-----
> From:	Johan Lim [SMTP:lim_johan hotmail com]
> Sent:	Wednesday, July 12, 2000 10:38 AM
> To:	redhat-list redhat com
> Subject:	binary file format under linux
> 
> Dear all,
> 
> I run a simulator program under linux.
> This simulator requires an input file
> in binary file format (xxx.bin).
> The contents of this input file is simply
> integers (unsigned).
> If anybody can point out how to make
> this binary file, i'd really appreciate.
> 
> Thanks,
> Johan
> 
> ________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
> 
> 
> -- 
> To unsubscribe: mail redhat-list-request redhat com with "unsubscribe"
> as the Subject.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]