/* assert.esim.c SJ */ #include #include #include void kopioi(float *a, float *b, int n); int main() { float x[3] = { 1.0, 2.0, 3.0 }; float *y = NULL; /* "unohdetaan" tilanvaraus */ /* y = (float*)malloc(3 * sizeof(float)); */ kopioi(y, x, 3); printf("Ohjelma päättyy\n"); free(y); exit(0); } void kopioi(float *a, float *b, int n) { int i; assert(a != NULL); assert(b != NULL); for (i = 0; i < n; i++) a[i] = b[i]; } /* Tämän ohjelman tulostus: assert.esim.c:28: failed assertion `a != NULL' Abort */