I am new to Ada, I need to make initialize a string with null characters, how can I do it? So far I can initialize a string with spaces as follows:
user_str : String(1..50) := (others => ' ');
user_str : String(1..50) := (others => Character'Val(0));
or
user_str : String(1..50) := (others => Ada.Characters.Latin_1.NUL);
Unlike some other languages, Ada does not have a special syntax for embedding speclal characters in character or string literals (like C's '\0', for example).
(Of course the latter requires an appropriate with clause.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With