Skip to content
Check out how to use the Utilities functions!

Utilities

Simple Usage Examples

Length Of

How long is a string?

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;
}

Output:

length_of-1-checker example