-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmalloc.c
More file actions
56 lines (47 loc) · 1.13 KB
/
Copy pathmalloc.c
File metadata and controls
56 lines (47 loc) · 1.13 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include<stdio.h>
#include<stdlib.h> // allocation library
int main()
{
int *p,i,number;
printf("Enter the number:\n");
scanf("%d",&number);
p = malloc(sizeof(int)*number);
printf("Enter the numbers\n");
for ( i = 0; i < number; i++)
scanf("%d",&p[i]);
printf("---------------------------------\n");
for ( i = 0; i <number; i++)
printf("%d \n",p[i]);
printf("\n");
printf("size of = %d\n",sizeof(p));
}
// #include<stdio.h>
// #include<stdlib.h>
// int main()
// {
// char *p ,i,n;
// printf("Enter the n value \n");
// scanf("%hhd",&n);
// p = malloc(sizeof(char)*n);
// for ( i = 0; i < n; i++)
// scanf("%s",p);
// for ( i = 0; i < n; i++)
// printf("%s ",p[i]);
// }
/* #include<stdio.h>
#include<stdlib.h>
int main()
{
char *p[5];
int i;
for(i=0;i<5;i++)
p[i] = (char *)malloc(20*sizeof(char));
printf("Enter the 5 strings\n");
for(i=0;i<5;i++)
scanf("%s",p[i]);
for(i=0;i<5;i++)
printf("%s\n",p[i]);
for(i=0;i<5;i++)
free(p[i]); // free memory else it has to be leak
}
*/