Example 14c

Examples 14-A, 14-B and 14-C attempt to show how undetected (at compile-time) array-bound errors can cause problems --- compile and run them:

    #include <stdio.h>
    #define UL 20

    /* If necessary, increase the value of UL to that in error_fourteen_a.c, 
       then compare what happens when you run the two programmes : 
     */

    main() {
        int a[10], j = 4000, i, k = 3000;

        printf("Value of j %d and k %d \n", j, k);

        for(i = 1; i <= UL; i++)
            a[i] = i*100;

        for (i = 1; i <= 10; i++)
            printf("%d \n",a[i]);

        printf("Value of j %d and k %d \n", j, k);
      }


...previousup (conts)next...



About this document:

Produced from the SGML: /home/isd/public_html/_course_crash_in_c/_reml_grp/practical_c.reml_lib
On: 3/3/2003 at 16:27:16
Options: reml2 -i noindex -l long -o html -p multiple