I want to reserve memory for a dynamic variable and assign value in the same function to avoid duplicating code, but I can not make the value take it in the main, it only remains in the function. Thank you very much
#include <stdio.h>
#include <stdlib.h>
void creadin(int *);
int main() {
int *a,*b,*c;
creadin(a); //no pongo ampersand porque al ser puntero ya es una direccion de memoria por lo cual deberia ser modificada
creadin(b);
creadin(c);
return 0;
}
void creadin(int *a){
a = (int *) malloc(sizeof(int));
scanf("%d", &(*a));
}