aboutsummaryrefslogtreecommitdiff
path: root/01_hello.zig
blob: a77d91943a232d7308f6a1030bd802598c59f161 (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
41
42
43
44
45
46
47
// 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".
//
// 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:
//
//     pub fn my_function() void { ... }
//
// 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", .{});

    // 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"
}

// 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!