summaryrefslogtreecommitdiff
path: root/C/HF/order_pizza.c
blob: aec19ac6fe18e3babc754cbc1714fc278f7a1f57 (plain)
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
#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, "Unknown 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;
}