...
Code Block | ||
---|---|---|
| ||
void f2() {
const size_t ARR_SIZE = 4;
float a[ARR_SIZE];
const size_t n= sizeof(float) * ARR_SIZE;
void *p = a;
memset(p, 0, n);
/* More program code */
}
|
...
Code Block | ||
---|---|---|
| ||
void f3(float *a, size_t val) {
float b = 3.14;
const size_t n = val;
void *p = a;
void *q = &b;
if( (n > sizeof(a)) || (n > sizeof(b)) ) {
/* Handle error */
}
else {
memcpy(p, q, n);
/* More program code */
}
}
|
...