/* Collection of code snippets by Arne Vajhøj */
/* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) */
#include <stdio.h>
#include <stdlib.h>

int main()
{
   int c;
   FILE *fp;
   fp = fopen("C:\\z.z", "wb");
   fputc('A', fp);
   fputc('\x1A', fp);
   fputc('B', fp);
   fclose(fp);
   fp = fopen("C:\\z.z", "rb");
   printf("binary: ");
   while((c = fgetc(fp)) != EOF)
   {
      printf(" %d", c);
   }
   printf("\n");
   fclose(fp);
   fp = fopen("C:\\z.z", "r");
   printf("text: ");
   while((c = fgetc(fp)) != EOF)
   {
      printf(" %d", c);
   }
   printf("\n");
   fclose(fp);
   return EXIT_SUCCESS;
}
