Next Up Previous Contents
Next: A.6 Mixed language programming
Up: A Example programs
Previous: A.4 Profiling
[ID index][Keyword index]

A.5 crash.c

The program crash.c crashes and dumps core. See Section 2.5.3 for discussion.


#include <stdio.h>

int bananas (int i)
{
    char buf[80];
    sprintf (buf, "banana number %d\n", i);    
    if (i != 0)
        fputs (buf, stdout);
    else
    {
        int *zp = 0;
        printf ("banana split: %d\n", *zp);
    }
    return 0;
}

int main (void)
{
    printf ("Entering the bananas function: 1\n");
    bananas (1);
    printf ("No bananas left!\n");
    bananas (0);
    printf ("We made it out!\n");
}


Next Up Previous Contents
Next: A.6 Mixed language programming
Up: A Example programs
Previous: A.4 Profiling
[ID index][Keyword index]
Theory and Modelling Resources Cookbook
Starlink Cookbook 13
Norman Gray
2 December 2001. Release 2-5. Last updated 10 March 2003