home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_09_06
/
9n06122a
< prev
next >
Wrap
Text File
|
1991-04-23
|
1KB
|
52 lines
#include <stdio.h>
#include <stdlib.h>
extern FILE *testfile;
/**************************************************************
* subroutine R : read a floating point number from test file
***************************************************************/
float
r()
{
float f;
int rc;
rewind(testfile);
rc = fread(&f, sizeof(float), 1, testfile);
if (rc != 1)
{
printf("R : read error\n");
exit(0);
}
printf("R : \tf = %f\n", f);
return f;
}
/****************************************************************
* subroutine W : write a floating point number in test file
****************************************************************/
int
w(f)
float f;
{
int rc; /* return code */
printf("W : \tf = %f\n", f);
rewind(testfile);
rc = fwrite(&f, sizeof(float), 1, testfile);
if (rc != 1)
{
printf("W : write error\n");
exit(0);
}
return 1;
}