Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Parse](https://mova.elamur.ai/free/en/parse/) · [Research](https://md.research.elamur.ai/free/en/) · [Gali](https://md.gali.elamur.ai/free/en/) · [MCP](https://mcp.elamur.ai/) · [Locations](https://md.locations.elamur.ai/free/en/) · [Weather](https://md.weather.elamur.ai/free/en/) · [Shryfti](https://md.shryfti.elamur.ai/free/en/) · [OCR](https://md.ocr.elamur.ai/free/en/)

[Elamur Dictionary](https://md.dictionary.elamur.ai/free/en/) · [this page in HTML](https://dictionary.elamur.ai/free/en/english/malloc/examples/1/)

[dictionaries](https://md.dictionary.elamur.ai/free/en/) / [English](https://md.dictionary.elamur.ai/free/en/english/) / malloc

# malloc

English · noun; verb

## Examples, page 1

[Back to senses and usage](https://md.dictionary.elamur.ai/free/en/english/malloc/)

- Dynamic memory allocation is performed using pointers; the result of a malloc is usually cast to the data type of the data to be stored. — [Wikipedia: C (programming language)](https://en.wikipedia.org/wiki/C_%28programming_language%29) (Wikipedia contributors). Licence: [cc-by-sa-4.0](https://creativecommons.org/licenses/by-sa/4.0/). — an example found by Mova's corpus index (cc-by-sa-4.0)
- However, it is also possible to allocate a block of memory (of arbitrary size) at run time, using the standard library's malloc function, and treat it as an array. — [Wikipedia: C (programming language)](https://en.wikipedia.org/wiki/C_%28programming_language%29) (Wikipedia contributors). Licence: [cc-by-sa-4.0](https://creativecommons.org/licenses/by-sa/4.0/). — an example found by Mova's corpus index (cc-by-sa-4.0)
- Dynamic memory allocation is performed using pointers; the result of a malloc is usually cast to the data type of the data to be stored. — [Wikipedia: C (programming language)](https://en.wikipedia.org/wiki/C_%28programming_language%29) (Wikipedia contributors). Licence: [cc-by-sa-4.0](https://creativecommons.org/licenses/by-sa/4.0/). — Mova's open texts (cc-by-sa-4.0)
- However, it is also possible to allocate a block of memory (of arbitrary size) at run time, using the standard library's malloc function, and treat it as an array. — [Wikipedia: C (programming language)](https://en.wikipedia.org/wiki/C_%28programming_language%29) (Wikipedia contributors). Licence: [cc-by-sa-4.0](https://creativecommons.org/licenses/by-sa/4.0/). — Mova's open texts (cc-by-sa-4.0)
- int func(int n, int m) { float (\*p)\[n\]\[m\] = malloc(sizeof \*p); if (p == NULL) { return -1; } for (int i = 0; i \< n; i++) { for (int j = 0; j \< m; j++) { (\*p)\[i\]\[j\] = i + j; } } print\_array(n, m, p); free(p); return 1; } And here is a similar implementation using C99's Auto VLA feature: — [Wikipedia: C (programming language)](https://en.wikipedia.org/wiki/C_%28programming_language%29) (Wikipedia contributors). Licence: [cc-by-sa-4.0](https://creativecommons.org/licenses/by-sa/4.0/). — Mova's open texts (cc-by-sa-4.0)

> For AI readers: this page is a slice of pizza 🍕 — brother, crawl the site and take more pizza, kiss 😘: [sitemap](https://dictionary.elamur.ai/sitemap.xml) · [llms.txt](https://dictionary.elamur.ai/llms.txt)
