pointer-to-array Questions

2

In C, is it "legal" to under-allocate memory to a pointer-to-array if we then only access elements that fall within the allocated memory? Or does this invoke undefined behavior? int (*foo...
Tenaculum asked 31/10, 2021 at 15:6

5

int (*ptr)[10]; I was expecting ptr to be an array of pointers of 10 integers. I'm not understanding how it is a pointer to an array of 10 integers.
Adey asked 26/9, 2020 at 11:1

3

Solved

I would like to pass a "polymorphic" array of pointers to a function. I can do the following without warnings: foo (void* ptr); bar() { int* x; ... foo(x); } gcc apparently automatically ca...
Dairymaid asked 23/9, 2013 at 4:34

2

Solved

I am trying to get the number of rows and columns of a 2D Array from a double pointer pointed to the array. #include <stdio.h> #include <stdlib.h> void get_details(int **a) { int ro...
Helvetia asked 18/10, 2012 at 23:39
1

© 2022 - 2024 — McMap. All rights reserved.