forked from Exoskill/C-headfirst
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pizza.c
41 lines (31 loc) · 791 Bytes
/
pizza.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 <unistd.h>
int main(int argc, char *argv[]){
char *delivery = "";
int thick = 0;
int count = 0;
char ch;
while ((ch = getopt(argc, argv, "d:t")) != EOF){
switch (ch){
case 'd':
delivery = optarg;
break;
case 't':
thick = 1;
break;
default:
fprintf(stderr, "Unknow option: '%s'\n", optarg);
return 1;
}
}
argc -= optind;
argv += optind;
if(thick)
puts("Thick crust.");
if(delivery[0])
printf("To be delivered %s \n", delivery);
puts("Ingredients:");
for(count = 0; count < argc; count++)
puts(argv[count]);
return 0;
}