Dear people that know more C than me (ie Everyone)
I am working on a simple bit of C code to fill a dynamic array with specific values and display them in a grid. However, I'm getting stuck at the beginning, when I try to allocate memory for the array. I have checked around for other calloc code, and I'm not sure where I'm making my mistake. When I try to compile my code, I receive an error that says: "incompatible implicit declaration of built-in function 'calloc'"
The code I'm using is as follows:
Please let me know if you what I'm doing wrong in my calloc statement. Thank you in advance!Code:#include<stdio.h> #include<math.h> main() { int i, j; //values to hold row & col size for array & mem size needed int col, row, Doubles; printf("\nEnter the number of columns desired for your array \n"); scanf("%d", &col); printf("\nEnter the number of rows desired for your array \n"); scanf("%d", &row); Doubles = col * row; //declaring the array //THIS IS WHERE I'M GETTING THE ERROR double *ArrayPtr = (double *) calloc (Doubles,sizeof(double)); //filling the array with the requested values for(i = 0; i < row; i++) for(j = 0; j < col; j++) { *ArrayPtr = i * 100 + col; ArrayPtr ++; }



LinkBack URL
About LinkBacks


