forked from fgrelard/GLGit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
enzyme.c
executable file
·41 lines (35 loc) · 994 Bytes
/
enzyme.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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "enzyme.h"
struct enzyme {
char *nom;
int poids;
};
ptr_enzyme creerenzyme() {
ptr_enzyme enz = (ptr_enzyme) malloc (sizeof(struct enzyme));
return enz;
}
ptr_enzyme saisie_enzyme(ptr_enzyme item) {
item = creerenzyme();
item->nom=(char *)malloc(sizeof(char) * 30);
printf("Veuillez entrez le nom\n");
scanf("%s", item->nom);
printf("Veuillez entrez le poids\n");
scanf("%d", &item->poids);
item=creer_enzyme(item->nom,item->poids);
return item;
}
ptr_enzyme creer_enzyme(char *_nom, int _poids) {
ptr_enzyme enz = (ptr_enzyme) malloc(sizeof(struct enzyme));
enz->nom=(char *) malloc(sizeof(char) * 30);
strcpy(enz->nom, _nom);
enz->poids=_poids;
return enz;
}
void affiche(ptr_enzyme enz) {
printf("Enzyme: %s, poids : %d\n", enz->nom, enz->poids);
}
void sauvegarde(ptr_enzyme enz, FILE* out) {
fprintf(out,"%s %d ", enz->nom, enz->poids);
}