/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
/* a sample program that opens a temporary file and
write a character and a string into it. */
#include <stdio.h>
#include <stdlib.h>

int main() {
    FILE *stream;
    char ch='A';
    char *name;
 
    if((name = tmpnam(NULL)) == NULL)
        printf("Error in creating temp file.\n");
    /* open file for reading only */
    if((stream=fopen(name,"w")) == NULL) { 
      printf("cannot open file\n");
      exit(1);
    }
    else {
        fputc(ch,stream);
        fputs("This is a test\n",stream);
        fputs("This is a test\n",stdout);
        fclose(stream);
    }
}
