I am trying to create a pointer to dynamic array and thus need a function that takes in the size of the array and returns the pointer. However, I am getting error every time i do it. The function itself gives no error, but the allocation does.
Can someone point out what might be wrong? I have read many pages online but can't seem to figure out still. It would greatly help!
Edit: Updated code:
int *ReturnBitVector(int bitvector_size); //static
int *ReturnBitVector(int bitvector_size) //static
{
int *bitvector = malloc((bitvector_size*1024*8)*sizeof *bitvector);
return bitvector;
}
int* BV = (int*)ReturnBitVector;
if(BV == NULL){ //error here!
perror("error in allocating memory.\n");
}
The error I get:
join.c:71: error: expected identifier or ‘(’ before ‘if’