[comp.lang.c] vax-c problem

DERMOTT@DREA-XX.arpa (Dave Dermott) (11/26/87)

Bug (or feature?) in VAX C v2.3
  I am porting a program from UNIX that uses fwrite to a binary file .On VMS
 the file must be 512 byte fixed format.

I'm having trouble with the fwrite function when writing to fixed
length 512 byte records. It doesn't write anything.

Simple example:

#include <stdio.h>
char buffer[512];
main()
{
int i,j;
FILE *fp;
for (i=0;i<512;i++)buffer[i]=i;
fp=fopen("testfix.dat","w","rfm=fix","mrs=512");
fwrite(buffer,1,512,fp);
fclose(fp);
}

After running this program I check the output file with:

$DIR/FULL TESTFIX.DAT

TESTFIX.DAT;11                File ID:  (9143,24,0)        
Size:            0/0          Owner:    [MATH,DERMOTT]
Created:  21-NOV-1987 21:03   Revised:  21-NOV-1987 21:03 (1)
Expires:   <None specified>   Backup:    <No backup done>
File organization:  Sequential
File attributes:    Allocation: 0, Extend: 0, Global buffer count: 0, No version limit
Record format:      Fixed length 512 byte records
Record attributes:  None
Journaling enabled: None
File protection:    System:RWED, Owner:RWED, Group:RWED, World:RE
Access Cntrl List:  None

 I.E. the file is empty!

   If I invert the 2nd and 3rd arguments it does write 512 bytes.
 i.e. fwrite(buffer,512,1,fp);
Am I doing something wrong?

David Dermott DERMOTT@DREA-XX.ARPA
Dartmouth Nova Scotia Canada

-------