This repository has been archived on 2024-12-16. You can view files and clone it, but cannot push or open issues or pull requests.
CodeBlocksPortable/WATCOM/samples/clibexam/alloca.c

29 lines
568 B
C
Raw Normal View History

#include <stdio.h>
#include <string.h>
#include <malloc.h>
FILE *open_err_file( char * );
void main()
{
FILE *fp;
fp = open_err_file( "alloca" );
if( fp == NULL ) {
printf( "Unable to open error file\n" );
} else {
fclose( fp );
}
}
FILE *open_err_file( char *name )
{
char *buffer;
/* allocate temp buffer for file name */
buffer = (char *) alloca( strlen(name) + 5 );
if( buffer ) {
sprintf( buffer, "%s.err", name );
return( fopen( buffer, "w" ) );
}
return( (FILE *) NULL );
}