aboutsummaryrefslogtreecommitdiff
path: root/exercises/43_pointers5.zig
diff options
context:
space:
mode:
authorDave Gauer <ratfactor@gmail.com>2021-02-15 19:32:00 -0500
committerGitHub <noreply@github.com>2021-02-15 19:32:00 -0500
commit09fd739efa9cee151c8300f53c422d8a72766d49 (patch)
tree45f2eba30d72f43df60cd9b053ebaea5dfe11f18 /exercises/43_pointers5.zig
parent0d212ecf5a9de1c0bb673a2b6a409de5a99a9d7b (diff)
parent304489ca1f465b5456fa8c21dd0ae4e4c6c48617 (diff)
downloadziglings-09fd739efa9cee151c8300f53c422d8a72766d49.tar.gz
ziglings-09fd739efa9cee151c8300f53c422d8a72766d49.tar.bz2
ziglings-09fd739efa9cee151c8300f53c422d8a72766d49.tar.xz
ziglings-09fd739efa9cee151c8300f53c422d8a72766d49.zip
Merge pull request #22 from quexxon/apply-zig-fmt
Apply `zig fmt` to exercises and generate remaining patch files
Diffstat (limited to 'exercises/43_pointers5.zig')
-rw-r--r--exercises/43_pointers5.zig19
1 files changed, 9 insertions, 10 deletions
diff --git a/exercises/43_pointers5.zig b/exercises/43_pointers5.zig
index dc178ec..cb94189 100644
--- a/exercises/43_pointers5.zig
+++ b/exercises/43_pointers5.zig
@@ -34,33 +34,32 @@
//
const std = @import("std");
-const Class = enum{
+const Class = enum {
wizard,
thief,
bard,
warrior,
};
-const Character = struct{
+const Character = struct {
class: Class,
gold: u32,
- health: u8 = 100, // <--- You can also fields a default value!
+ health: u8 = 100, // <--- You can also provide fields a default value!
experience: u32,
};
pub fn main() void {
var glorp = Character{
- .class = Class.wizard,
- .gold = 10,
+ .class = Class.wizard,
+ .gold = 10,
.experience = 20,
};
// FIX ME!
// Please pass our Character "glorp" to printCharacter():
- printCharacter( ??? );
+ printCharacter(???);
}
-
// Note how this function's "c" parameter is a pointer to a Character struct.
fn printCharacter(c: *Character) void {
@@ -68,9 +67,9 @@ fn printCharacter(c: *Character) void {
// don't have to write the full enum name. Zig understands that ".wizard"
// means "Class.wizard" when we switch on a Class enum value:
const class_name = switch (c.class) {
- .wizard => "Wizard",
- .thief => "Thief",
- .bard => "Bard",
+ .wizard => "Wizard",
+ .thief => "Thief",
+ .bard => "Bard",
.warrior => "Warrior",
};