How to resolve the algorithm Array length step by step in the Zig programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Array length step by step in the Zig programming language
Table of Contents
Problem Statement
Determine the amount of elements in an array.
As an example use an array holding the strings 'apple' and 'orange'.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Array length step by step in the Zig programming language
Source code in the zig programming language
const std = @import("std");
pub fn main() !void {
// left hand side type can be ommitted
const fruit: [2][]const u8 = [_][]const u8{ "apples", "oranges" };
const stdout_wr = std.io.getStdOut().writer();
// slices and arrays have an len field
try stdout_wr.print("fruit.len = {d}\n", .{fruit.len});
}
You may also check:How to resolve the algorithm Sudoku step by step in the PureBasic programming language
You may also check:How to resolve the algorithm Averages/Arithmetic mean step by step in the D programming language
You may also check:How to resolve the algorithm Population count step by step in the Crystal programming language
You may also check:How to resolve the algorithm Hamming numbers step by step in the Yabasic programming language
You may also check:How to resolve the algorithm Make directory path step by step in the Perl programming language