From 973e27b243ea7f12b6743894465c67a4a6a87eb2 Mon Sep 17 00:00:00 2001 From: Carlos Maiolino Date: Sat, 6 Sep 2025 09:26:21 +0200 Subject: Move some other code here Signed-off-by: Carlos Maiolino --- C/HF/order_pizza.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 C/HF/order_pizza.c (limited to 'C/HF/order_pizza.c') diff --git a/C/HF/order_pizza.c b/C/HF/order_pizza.c new file mode 100644 index 0000000..aec19ac --- /dev/null +++ b/C/HF/order_pizza.c @@ -0,0 +1,40 @@ +#include +#include + +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; +} -- cgit v1.2.3