-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpit1.c
More file actions
32 lines (30 loc) · 708 Bytes
/
Copy pathpit1.c
File metadata and controls
32 lines (30 loc) · 708 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <stdio.h>
#include <stdlib.h>
void allocate (int **p,int value){
if (*p != NULL){
printf("\nmemoory is not free");
free(*p);
}
*p= malloc(sizeof(int));
if (*p ==NULL){
printf("\nmemory can't be allocated");
return
}
**p = value;
}
int main(){
int *ptr =NULL;
allocate(&ptr,24);
printf("\nthe vaule of the %p\n",(void*)ptr);
printf("\nthe value of the ptr %d\n", *ptr);
printf("\nthe value of the %p\n ",(void*)&ptr);
free(ptr);
ptr= NULL;
allocate(&ptr,35);
printf("\nthe vaule of the %p\n",(void*)ptr);
printf("\nthe value of the ptr %d\n", *ptr);
printf("\nthe value of the %p\n ",(void*)&ptr);
free(ptr);
ptr= NULL;
return 0;
}