The following code shows an example of using Length Of to check the length of different strings.
#include "splashkit.h" int main(){ // Array of strings to analyse string texts[7] = {"SplashKit", "Hello", "12345", "A quick brown fox leaps high", "3.141592653589793", "hi", ""}; // Loop through each string and print its length for (int i = 0; i < 7; i++) { string text = texts[i]; int length = length_of(text); // Get the length of the string write_line("The length of '" + text + "' is:" + std::to_string(length) + " characters."); } return 0;}
using static SplashKitSDK.SplashKit; // Array of strings to analysestring[] texts = { "SplashKit", "Hello", "12345", "A quick brown fox leaps high", "3.141592653589793", "hi", "" }; // Loop through each string and print its lengthforeach (string text in texts){ int length = LengthOf(text); // Get the length of the string WriteLine($"The length of '{text}' is: {length} characters.");}
using SplashKitSDK; namespace LengthOfExample{ public class Program { public static void Main() { // Array of strings to analyse string[] texts = { "SplashKit", "Hello", "12345", "A quick brown fox leaps high", "3.141592653589793", "hi", "" }; // Loop through each string and print its length foreach (string text in texts) { int length = SplashKit.LengthOf(text); // Get the length of the string SplashKit.WriteLine($"The length of '{text}' is: {length} characters."); } } }}
from splashkit import * # Array of strings to analysetexts = ["SplashKit", "Hello", "12345", "A quick brown fox leaps high", "3.141592653589793", "hi", ""] # Loop through each string and print its lengthfor text in texts: length = length_of(text) # Get the length of the string write_line(f"The length of '{text}' is: {length} characters.")
Output: