aboutsummaryrefslogtreecommitdiff
path: root/01_hello.zig
diff options
context:
space:
mode:
authorDave Gauer <dave@ratfactor.com>2021-01-03 12:21:11 -0500
committerDave Gauer <dave@ratfactor.com>2021-01-03 12:21:11 -0500
commitd618414c9cd144e3d63f2b12df7b512b98df041c (patch)
tree2b62be68efd03c9454eab640966abf0dc0d21793 /01_hello.zig
parent3b5678815f010bd016ca561e4672d2d83271cb2e (diff)
downloadziglings-d618414c9cd144e3d63f2b12df7b512b98df041c.tar.gz
ziglings-d618414c9cd144e3d63f2b12df7b512b98df041c.tar.bz2
ziglings-d618414c9cd144e3d63f2b12df7b512b98df041c.tar.xz
ziglings-d618414c9cd144e3d63f2b12df7b512b98df041c.zip
Added Ex. 2, polished script, added LICENSE
Diffstat (limited to '01_hello.zig')
-rw-r--r--01_hello.zig49
1 files changed, 9 insertions, 40 deletions
diff --git a/01_hello.zig b/01_hello.zig
index a77d919..d61a999 100644
--- a/01_hello.zig
+++ b/01_hello.zig
@@ -1,47 +1,16 @@
-// Oh no! This program is supposed to print "Hello world!" but it has some
-// mistakes. Let's fix it.
//
-// We're trying to import the Standard Library into the top level of our
-// application. The standard library is not named "foo", it is named "std".
+// Oh no! This program is supposed to print "Hello world!" but it needs
+// your help!
//
-// Please correct the name in both places in the import here:
-const foo = @import("foo");
-
-// Zig applications start by calling a function named 'main'. It needs to be
-// public so that it is accessible outside our file!
-//
-// Public functions are declared with the 'pub' keyword like so:
+// Hint: Zig functions are private by default.
+// The main() function should be public.
+// Declare a public function with "pub fn ..."
//
-// pub fn my_function() void { ... }
+// Try to fix the program and run `ziglings` to see if it passes.
//
-// Please make the main() function public:
-fn main() void {
-
- // The easiest way to display our "Hello world" message in the
- // terminal is to use the std.debug.print() function.
-
- // Please fix this silly "foo" mistake here:
- foo.debug.print("Hello world!\n", .{});
+const std = @import("std");
- // The print function above takes two values:
- //
- // 1. A string of characters: "Hello world!\n". "\n" prints a new line.
- //
- // 2. A struct containing data to be displayed. .{} is an empty, nameless
- // struct fulfilling the requirement. More about structs later.
- //
- //
- // Now we're ready to...What's this!? Oh, we wanted to print a Goodbye
- // message as well!
- //
- // Please fix this to use the same print function as above:
- "Goodbye!\n"
+fn main() void {
+ std.debug.print("Hello world!\n", .{});
}
-// Once you're done with the changes above, run `ziglings` to see if it passes.
-//
-// Finally, all files will contain the following comment:
-//
-// I AM NOT DONE
-//
-// Delete it when you're ready to continue to the next exercise!