1
0
mirror of https://gitlab.com/80486DX2-66/gists synced 2024-12-24 13:49:46 +05:30

countLettersInTextFile.d: use argv[1] instead of "file.txt"

This commit is contained in:
Intel A80486DX2-66 2024-03-14 22:09:50 +03:00
parent c8e2aa3308
commit 4a81d7cd47
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B

View File

@ -4,9 +4,9 @@ import std.ascii : isAlpha, isWhite;
import std.file : read;
import std.stdio : writefln;
void main()
void main(string[] argv)
{
auto fileContent = cast(string)read("file.txt");
auto fileContent = cast(string)read(argv[1]);
auto totalLetters =
count(filter!(a => isAlpha(a) || isWhite(a))(fileContent));
auto percentage = (totalLetters * 100) / cast(double)fileContent.length;