func
English · noun
Examples, page 1
- int func(int n, int m) { // Caution: checks should be made to ensure n * m * sizeof(float) does NOT exceed limitations for auto VLAs and is within available size of stack. float p[n][m]; // auto VLA is held on the stack, and sized when the function is invoked for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { p[i][j] = i + j; } } print_array(n, m, p); // no need to free(p) since it will disappear when the function exits, along with the rest of the stack frame return 1; } — Wikipedia: C (programming language) (Wikipedia contributors). Licence: cc-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) (Wikipedia contributors). Licence: cc-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) (Wikipedia contributors). Licence: cc-by-sa-4.0. — an example found by Mova's corpus index (cc-by-sa-4.0)
This page in Markdown https://md.dictionary.elamur.ai/free/en/english/func/examples/1/