IHYPRESS.NET
C
HOME | ASP | C | CSS | HTML | JAVASCRIPT | PERL | PHP | PYTHON | RUBY | SVG
Earn Free Bitcoin
COne Dimensional Arrays ❯ Dynamic Allocation
<07.09>
/* A dynamically-allocated 1-D array */ #include <stdio.h> #include <stdlib.h> int main (void) { double* array; //declare a pointer only int i, size; //ask user for size of array printf ("How large do you want your array? "); scanf ("%d", &size); //allocate the array in the heap with calloc array = (double *) calloc (size, sizeof(double)); //printing the array for verification. calloc initializes all cells to 0. for (i = 0; i < size; ++i) printf ("%6.2lf", array[i]); //freeing the memory allocation free (array); return (0); }
Hergestellt in Deutschland / Made in Germany
How large do you want your array? 7 0.00 0.00 0.00 0.00 0.00 0.00 0.00
COPYRIGHT © 2015-2024 IHYPRESS.NET. A DIVISION OF IHY PRESS. ALL RIGHTS RESERVED.