Ajout union

This commit is contained in:
EyeXion 2020-10-01 17:06:21 +02:00
parent 4805fe44c5
commit 20974fba6d
2 changed files with 13 additions and 3 deletions

View file

@ -36,7 +36,7 @@ void init(struct pile ** une_pile) {
*une_pile = (struct pile *)malloc(sizeof(struct pile));
}
void push(int e, struct pile * une_pile) {
void push(Valeur e, struct pile * une_pile) {
struct cell * aux;
if (une_pile->taille == 0) {
une_pile->taille = 1;

View file

@ -1,8 +1,18 @@
#ifndef PILE_H
#define PILE_H
enum Type_t {reel,entier};
typedef struct Valeur{
union
{
int valentier;
float valreel;
}val;
enum Type_t type;
}Valeur;
struct cell {
int val;
Valeur val;
struct cell * suiv;
};
@ -13,7 +23,7 @@ struct pile {
void init(struct pile ** une_pile);
int pop(struct pile * une_pile);
void push(int e, struct pile * une_pile);
void push(Valeur e, struct pile * une_pile);
void print(struct pile une_pile);
#endif