home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / compiler / alib / betest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-27  |  1.1 KB  |  62 lines

  1. #include <stdio.h>
  2. #include <dos/dos.h>
  3. #include <proto/exec.h>
  4. #include <proto/dos.h>
  5. #include <proto/alib.h>
  6. #include <proto/aros.h>
  7.  
  8. int main (int argc, char ** argv)
  9. {
  10.     BPTR fh;
  11.     UBYTE b;
  12.     UWORD w;
  13.     ULONG l;
  14.     FLOAT f;
  15.     DOUBLE d;
  16.     STRPTR s = NULL;
  17.  
  18.     fh = Open ("test.bed", MODE_NEWFILE);
  19.  
  20.     if (!fh)
  21.     {
  22.     printf ("Couldn't open file (1)\n");
  23.     return 10;
  24.     }
  25.  
  26.     WriteByte (fh, 0x11);
  27.     WriteWord (fh, 0x1122);
  28.     WriteLong (fh, 0x11223344);
  29.     WriteString (fh, "Hello world.");
  30.     WriteFloat (fh, 1.5);
  31.     WriteDouble (fh, 1.75);
  32.  
  33.     Close (fh);
  34.  
  35.     fh = Open ("test.bed", MODE_OLDFILE);
  36.  
  37.     if (!fh)
  38.     {
  39.     printf ("Couldn't open file (2)\n");
  40.     return 10;
  41.     }
  42.  
  43.     ReadByte (fh, &b);
  44.     kprintf ("Byte = %02x\n", b);
  45.     ReadWord (fh, &w);
  46.     kprintf ("Word = %04x\n", w);
  47.     ReadLong (fh, &l);
  48.     kprintf ("Long = %08lx\n", l);
  49.     ReadString (fh, &s);
  50.     kprintf ("String = \"%s\"\n", s);
  51.     ReadFloat (fh, &f);
  52.     kprintf ("Float = %08lx\n", ((ULONG *)&f)[0]);
  53.     ReadDouble (fh, &d);
  54.     kprintf ("Double = %08lx%08lx\n", ((ULONG *)&d)[1], ((ULONG *)&d)[0]);
  55.  
  56.     FreeVec (s);
  57.  
  58.     Close (fh);
  59.  
  60.     return 0;
  61. }
  62.