/* Copyright (c) 2001-2004 by SoftIntegration, Inc. All Rights Reserved */
/* This is an example for the function fputws(const wchar_t *, FILE *).  
   It will place a wide character string into the specifed file.  
   If the file does not exist, one will be created.
*/
#include <wchar.h>

int main() {
    FILE *stream;
    wchar_t line[100];
    char *temp, *name;
    int len;
   
    if((name = tmpnam(NULL)) == NULL) 
    	printf("temp file name could not be made. \n");
    else {
    	temp ="Have a Nice Day!";
    	len = strlen(temp);
    	mbstowcs(line, temp, len);
    	if((stream = fopen(name, "w")) != NULL) {   
            fputws(line, stream);
            fputws(line, stdout);
            fputs("\n", stdout);
    	}
        else
            printf("Error in opening file!\n");
    }
    fclose(stream);
    remove(name);
}

