forked from IshatV412/ICS_Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariables.c
More file actions
64 lines (56 loc) · 1.78 KB
/
Copy pathvariables.c
File metadata and controls
64 lines (56 loc) · 1.78 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
57
58
59
60
61
62
63
64
#include<stdio.h>
#include<stdlib.h>
#include"dictionary.c"
//#include "all lib.h"
typedef struct vectors{
void *variable;
}vectors;
typedef struct{
int capacity;
int vars;
int type;
vectors *vector_var;
}variables;
variables* variable_initialiser(){
variables variable_list[11];
for(int i = 0; i < 10; i++){
variable_list[i].capacity = 1;
variable_list[i].vars = 0;
variable_list[i].type = i;
variable_list[i].vector_var = (vectors *)malloc(sizeof(vectors));
variable_list[i].vector_var->variable = NULL;
}
return variable_list;
}
void increase_var_list(int type, variables *variable_list){
if(variable_list[type].capacity <= variable_list[type].vars){ //only increase if needed
variable_list[type].capacity *= 2;
variable_list[type].vector_var = (vectors *)realloc(variable_list[type].vector_var,variable_list[type].capacity * sizeof(vectors));
for(int i = variable_list[type].vars; i < variable_list[type].capacity; i++){
variable_list[type].vector_var[i].variable = NULL;
}
}
}
vectors* Add_variable(int type, variables *variable_list,char name[50]){
if(variable_list[type].vars >= variable_list[type].capacity){
increase_var_list(type, variable_list);
}
for(int i=0; i<variable_list[type].capacity;i++){
if(variable_list[type].vector_var[i].variable == NULL){
if(type == 0){
variable_list[type].vector_var[i].variable = (dictionary_C_C *)create_dictionary_C_C(1,name);
}
//else if other all variables
}
}
}
int main(void){
printf("Hi");
return 0;
}
/*
10 Variables types
capacity
no.of variables
vector locations
*/