[R] read file with readBin (the file was saved with a C-routine)

From: Jörn Schulz <noah78_at_web.de>
Date: Thu 29 Jun 2006 - 01:48:00 EST


Hello!

I have problems with using of "readBin" to read files, which was written in C with "fwrite". In the C-File there is the following Code:

fwrite(MyitINI,sizeof(itINItype),1,outfile);

where MyitINI is a structure of the following form

typedef struct{

 int  KernelFileSave;      /* Determined, if Systemmatrix saved or not.*/
 char KernelFileName[200]; /* A-Matrix name                            */
 char StartFileName[200];  /* Startguess (optional)                    */
 int XSamples;             /* No of samples on 1. axis of recon image  */
 int YSamples;             /* No of samples on 2. axis of recon image  */
 float DeltaX;             /* Sampling distance 1. axis of recon image */
 float DeltaY;             /* Sampling distance 2. axis of recon image */
 float Xmin;               /* 1. sample position 1.axis of recon image */
 float Ymin;               /* 1. sample position 2.axis of recon image */
 } itINItype;

I thought the following use of "readBin" sould it do, but it doesn't

KernelFileSave <- readBin( con, integer(), n=1, size=4 ) KernelFileName <- readBin( con, character(), n=1 ) StartFileName <- readBin( con, character(), n=1 ) XSamples <- readBin( con, integer(), n=1, size=4 ) YSamples <- readBin( con, integer(), n=1, size=4 ) DeltaX <- readBin( con, numeric(), n=1, size=4 ) DeltaY <- readBin( con, numeric(), n=1, size=4 ) Xmin <- readBin( con, numeric(), n=1, size=4 ) Ymin <- readBin( con, numeric(), n=1, size=4 )

I think there is a problem if I read the character. Have you any ideas ???

Thanks for help.
Jörn Schulz.



Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jun 29 01:53:28 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 29 Jun 2006 - 04:13:07 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.