From 9c2b89aae54bed2ea91fb03d5ccbfe2fe015900c Mon Sep 17 00:00:00 2001 From: Cian Bagshaw Date: Fri, 25 Nov 2022 02:58:55 +0000 Subject: [PATCH] Added exercise 1-1 --- 1/1.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 1/1.c diff --git a/1/1.c b/1/1.c new file mode 100644 index 0000000..ef05a90 --- /dev/null +++ b/1/1.c @@ -0,0 +1,28 @@ +/* + Exercise 1-1. Run the "hello, world" program on your system. Experiment with + leaving out parts of the program, to see what error messages you get. + === + + On executing the full program I got a warning from GCC, as I had not specified + the return type of the "main" function, as the "-Wimplicit-int" option is + enabled by default. As per the man page, this can be disabled by passing the + argument "-Wno-implicit-int". I can also suppress the message by simply + specifying the return type, stating "int" before "main". Trying both of these + suppressed the message, though I left the code as in the text. Nonetheless, the + code compiles and works either way. + + On removing the "include" statement, GCC warns me of an implicit declaration of + "printf", noting that I must include "stdio.h" or define "printf". Though GCC, + being intelligent, compiles nonetheless. + + On removing "main", compilation failed, and I got an error, as the compiler + expected an identifier before the parenthesis. + + Removal of the curly braces results in simple failure. +*/ + +#include + +main () { + printf("hello, world\n"); +} -- 2.20.1