//указатель на значение int
int *pInt = malloc(sizeof *pInt);
//malloc возвращает nullptr, когда память кончилась
if (pInt == nullptr) {
return 1;
}
*pInt = 50;
//указатель на double
double *pDouble = malloc(sizeof *pDouble);
if (pDouble == nullptr) {
free(pInt);
return 1;
}
double d = 3.14;
*pDouble = d;
//*pInt is 50
//*pDouble is 3.14
printf("*pInt is %d\n", *pInt);
printf("*pDouble is %g\n", *pDouble);
//Освобождение памяти: после free значение читать нельзя
free(pInt);
free(pDouble);