Here, we will create string literals using &str type. The value of string literal is known at compile-time, and we will print the length of the string literal using the string.len() function.
Here, we created a string literal message using &str type. Then we printed the values of the created string literal and its length on the console screen.
Program/Source Code:
The source code to print the length of string literal is given below. The given program is compiled and executed successfully.
Output:
Explanation:
Here, we created a string literal message using &str type. Then we printed the values of the created string literal and its length on the console screen.
need an explanation for this answer? contact us directly to get an explanation for this answer