From 2bdacd35c1325a504685f65d450f9402a5344502 Mon Sep 17 00:00:00 2001 From: Dave Gauer Date: Wed, 10 Feb 2021 22:13:22 -0500 Subject: Added string specifier in format strings (#3) This is now required in current versions of Zig. --- exercises/06_strings.zig | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'exercises/06_strings.zig') diff --git a/exercises/06_strings.zig b/exercises/06_strings.zig index d469166..1d3da1a 100644 --- a/exercises/06_strings.zig +++ b/exercises/06_strings.zig @@ -35,11 +35,12 @@ pub fn main() void { // That's all the problems. Let's see our results: std.debug.print("d={u} {s}{s}\n",.{d, laugh, major_tom}); // - // Keen eyes will notice that we've put a 'u' inside the '{}' - // placeholder in the format string above. This tells the - // print() function to format the values as a UTF-8 character. - // If we didn't do this, we'd see '100', which is the decimal - // number corresponding with the 'd' character in UTF-8. + // Keen eyes will notice that we've put 'u' and 's' inside the '{}' + // placeholders in the format string above. This tells the + // print() function to format the values as a UTF-8 character and + // UTF-8 strings respectively. If we didn't do this, we'd see '100', + // which is the decimal number corresponding with the 'd' character + // in UTF-8. (And an error in the case of the strings.) // // While we're on this subject, 'c' (ASCII encoded character) // would work in place for 'u' because the first 128 characters -- cgit v1.2.3-70-g09d2