Hi All.. I cannot find the mistake in this code.
PS: I don't want to change my function to "int create_vect (void)". I'd like to know why it doesn't work in THIS wayCode:#include <stdio.h>
#include <stdlib.h>
void create_vect (int** v) {
*v = (int *) malloc(2 * sizeof(int));
*v[0] = *v[1] = 85;
}
int main()
{
int* v;
create_vect(&v);
printf("%d %d\n", v[0], v[1]); //it prints "85 0". Why? It should be "85 85"
return 0;
}
Thank you in advance !!!!