maybe it's a dumb question but I'm new in C. I'm trying to return a pointer from a function using malloc. I made an array with strtok. Here it's the code of the function from which I'm trying to return the pointer:
int *data(){
    
  int longi=0, *array=(int *) malloc(4 * sizeof(int));
  char buffer[1024];     
  char *aux;       
  printf("Enter if approved(A) or failed (F) separated by a comma \",\": \n");
  fgets(buffer,1023,stdin); 
  aux=strtok(buffer, ","); 
  while(aux)                 
  {
      array[longi]=aux; 
      longi++;                 
      aux=strtok(NULL, ","); 
  } 
  printf("%s", array[0]);
  return array;
}
And here is my main function:
int main(){
  int *arr=data();
  printf("%s",arr[0]); /*segmentation error */
  return 0;
}
 
     
     
    