008_quiz.zig 792 B

12345678910111213141516171819202122232425262728293031323334
  1. //
  2. // Quiz time! Let's see if you can fix this whole program.
  3. //
  4. // This is meant to be challenging.
  5. //
  6. // Let the compiler tell you what's wrong.
  7. //
  8. // Start at the top.
  9. //
  10. const std = @import("std");
  11. pub fn main() void {
  12. // What is this nonsense? :-)
  13. const letters = "YZhifg";
  14. const x: u8 = 1;
  15. // This is something you haven't seen before: declaring an array
  16. // without putting anything in it. There is no error here:
  17. var lang: [3]u8 = undefined;
  18. // The following lines attempt to put 'Z', 'i', and 'g' into the
  19. // 'lang' array we just created.
  20. lang[0] = letters[x];
  21. x = 3;
  22. lang[???] = letters[x];
  23. x = ???;
  24. lang[2] = letters[???];
  25. // We want to "Program in Zig!" of course:
  26. std.debug.print("Program in {s}!\n", .{lang});
  27. }