-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArray.c
More file actions
35 lines (33 loc) · 745 Bytes
/
Array.c
File metadata and controls
35 lines (33 loc) · 745 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
33
34
35
#include<stdio.h>
#include<stdlib.h>
struct myarray{
int total_size ;
int used_size;
int *ptr;
};
void createarray(struct myarray *a, int tsize, int usize) {
(*a).total_size = tsize;
(*a).used_size = usize;
(*a).ptr = (int*)malloc(tsize* sizeof(int));
}
void show (struct myarray *a){
for (int i =0; i< (*a).used_size; i++ ){
printf ("%d \n", ((*a).ptr)[i]);
}
};
void setvalue (struct myarray *a){
int n;
for (int i = 1; i < (*a).used_size; i++)
{
printf("enter the value %d \n" , i );
scanf ("%d" , &n);
(*a).ptr[i] = n;
}
}
int main(){
struct myarray marks;
createarray(&marks, 100, 3);
setvalue (&marks);
show (&marks);
return 0;
}