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
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {char name[30] ;
int quantite;} item_t;
int item_fill(item_t* obj, char a[], int quantite);
int inventory_display(item_t* tab);
int inventory_add(item_t* inventory, item_t item);
int main()
{
int nbr1=1;
char nom1;
char* name1 = NULL;
item_t* objet1 = NULL;
name1=&nom1;
objet1 = (item_t*) malloc(30*sizeof(item_t));
scanf("%s",nom1);
/*scanf("%i",&nbr1);*/
item_fill(&objet1, name1, nbr1);
inventory_display(objet1);
printf("%i '%s' \n",objet1->quantite,objet1->name);
return 0;
}
int item_fill(item_t* obj, char* a, int quantite)
{
strcpy(obj->name,a);
obj->quantite=quantite;
return 0;
} |
Partager