-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfood.c
More file actions
31 lines (26 loc) · 751 Bytes
/
food.c
File metadata and controls
31 lines (26 loc) · 751 Bytes
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
#include <stdlib.h>
#include <stdio.h>
#include "food.h"
struct Food *newfood(struct Food *food)
{
/* Allocate space for new element/node: */
struct Food *new_food = (struct Food *)malloc(sizeof(struct Food));
printf("Name: ");
scanf("%s",new_food->name);
printf("Carbohydrates: ");
scanf("%i",&new_food->carbohydrates);
printf("protin: ");
scanf("%i",&new_food->protin);
printf("fat: ");
scanf("%i",&new_food->fat);
/* We increment since we just added a beer */
return new_food;
}
void seefood(struct Food *food)
{
printf("Name: %s\n", food->name);
printf("Carbohydrates: %d\n", food->carbohydrates);
printf("protin: %d\n", food->protin);
printf("fat: %d\n", food->fat);
food = food->next;
}