-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtable_symbole.c
57 lines (52 loc) · 1.17 KB
/
table_symbole.c
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "table_symbole.h"
void ajouter_symbole(symbole s, table_symbole t){
int i = 0;
while (strcmp(t[i].nom,"\0") != 0 && strcmp(t[i].nom,s.nom) != 0)
{
i++;
}
//t[i].nom = s.nom;
strcpy(t[i].nom, s.nom);
t[i].val = s.val;
}
symbole cree_symbole(char* nom, int val){
symbole s;
strcpy(s.nom, nom);
s.val = val;
return s;
}
void afficher_table(table_symbole t){
printf("\n**********************\n");
printf("* nom | val *\n");
int i = 0;
while (strcmp(t[i].nom,"\0") != 0)
{
printf("* %s | %d *\n", t[i].nom, t[i].val);
i++;
}
printf("**********************\n");
}
void init_table(table_symbole t,int taille_table){
for (int i = 0; i < taille_table; i++)
{
//t[i].nom = "\0";
strcpy(t[i].nom, "\0");
t[i].val = 0;
}
}
int chercher(char* var, int* v, table_symbole t){
int i = 0;
while (strcmp(t[i].nom,"\0") != 0)
{
if (!strcmp(t[i].nom, var))
{
*v = t[i].val;
return 1;
}
i++;
}
return 0;
}