The size of dynamic array is the twice the size of static array. I want to assign the values which starts from (N/2)-1 to N-1 of dynamic array to whole static array.
The only way is copying the values with a loop?
My code:
#include <stdio.h> #include <stdlib.h> #include <math.h> int main(int argc, char *argv[]) { int N=100, pSize=4, lSize, i; double *A; lSize=N/sqrt(pSize); /* memory allocation */ A=(double*)malloc(sizeof(double)*N); double B[lSize]; /* memory allocation has been done */ /* initilize arrays */ for(i=0; i<lSize; i++){ B[i]=rand()% 10; } A=B; for (i=0; i<lSize; i++){ fprintf(stdout,"%f\n", A[i]); } return 0; }