How to loop through characters of a string in D language?
forkit
forkit at gmail.com
Sat Dec 11 08:46:32 UTC 2021
On Saturday, 11 December 2021 at 08:05:01 UTC, Ola Fosheim
Grøstad wrote:
>
> Using libraries can trigger hidden allocations.
ok. fine. no unnecessary, hidden allocations then.
// ------------------
module test;
import core.stdc.stdio : putchar;
nothrow @nogc void main()
{
string str = "abc;def;ab";
ulong len = str.length;
for (ulong i = 0; i < len; i++)
{
if (cast(int) str[i] != ';')
putchar(cast(int) str[i]);
}
}
// ------------------
More information about the Digitalmars-d-learn
mailing list