You need to adjust the *a pointer, this means you need to pass a pointer to the *a. You do that like this:
int *a;
void initArray( int **arr )
{
*arr = malloc( sizeof( int ) * SIZE );
}
int main()
{
initArray( &a );
return 0;
}
More Related Contents:
- what is meant by (void *) variable and (void *) & variable in C [closed]
- I had issue in below mention program to assign a value to the pointer.String concatenation Program( *s1=*s2) [closed]
- Segmentation Fault in C(core dumped)–simple pointer [closed]
- How to find the ‘sizeof’ (a pointer pointing to an array)?
- Crash or “segmentation fault” when data is copied/scanned/read to an uninitialized pointer
- How come an array’s address is equal to its value in C?
- Pointer Arithmetic [closed]
- What is the difference between char array and char pointer in C?
- Why is the asterisk before the variable name, rather than after the type?
- What’s the difference between a VLA and dynamic memory allocation via malloc?
- Why does this implementation of offsetof() work?
- Why can’t I cast a function pointer to (void *)?
- Constant pointer vs Pointer to constant [duplicate]
- Can the size of pointers vary between data and function pointers?
- Function to dynamically allocate matrix
- Using fseek with a file pointer that points to stdin
- What happens in OS when we dereference a NULL pointer in C?
- Pointer vs array in C, non-trivial difference
- Passing arrays and matrices to functions as pointers and pointers to pointers in C
- Is it good practice to free a NULL pointer in C? [duplicate]
- change pointer passed by value
- Why can I change the value of a const char* variable?
- Accesing a 2D array using a single pointer
- Declare and initialize pointer concisely (i. e. pointer to int)
- Triple pointers in C: is it a matter of style?
- C: pointer to array of pointers to structures (allocation/deallocation issues)
- How to explain C pointers (declaration vs. unary operators) to a beginner?
- Why does NSError need double indirection? (pointer to a pointer)
- What is the real difference between Pointers and References?
- Does C have an equivalent of std::less from C++?