Why does b
not hold 1., 2.
?
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#define LEN 2
void main() {
double a[LEN] = {1, 2};
double* b = malloc(LEN * sizeof(*b));
memcpy(b, a, LEN);
for (size_t i = 0; i < LEN; i++)
{
printf("%.2f ", b[i]);
}
printf("\n");
}
Instead, I get
> gcc code.c
> ./a.out
0.00 0.00