#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <limits.h>

int main()
{
    // try to create an array of LONG_MAX size,
    // i.e. 9223372036854775807 bytes!
    char* massive_array = malloc(LONG_MAX) ;

    // Check if array was created
    if( !massive_array ) {
        // Uh oh! Looks like Array creation failed.
        // print the errno
        printf( "errno = %d\n", errno ) ;

        // Send custom error message and also print system message
        perror( "My Massive Array creation failed!" ) ;
    }

    // can set errno explicitly
    errno = 100 ;
    char *error_string = strerror(errno) ;
    printf( "\nerrno = %d\t (standard) String = %s\n", errno, error_string ) ;

    // can give it any input, really
    unsigned int my_errno = 9999 ;
    error_string = strerror( my_errno ) ;
    printf( "\nmy_errno = %d\t (custom) String = %s\n", my_errno, error_string ) ;

    printf("\n") ;
    return 0 ;
}
