mirror of
https://gitlab.com/80486DX2-66/gists
synced 2024-11-08 18:02:23 +05:30
countLettersInTextFile.d: use argv[1]
instead of "file.txt"
This commit is contained in:
parent
c8e2aa3308
commit
4a81d7cd47
@ -4,9 +4,9 @@ import std.ascii : isAlpha, isWhite;
|
|||||||
import std.file : read;
|
import std.file : read;
|
||||||
import std.stdio : writefln;
|
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 =
|
auto totalLetters =
|
||||||
count(filter!(a => isAlpha(a) || isWhite(a))(fileContent));
|
count(filter!(a => isAlpha(a) || isWhite(a))(fileContent));
|
||||||
auto percentage = (totalLetters * 100) / cast(double)fileContent.length;
|
auto percentage = (totalLetters * 100) / cast(double)fileContent.length;
|
||||||
|
Loading…
Reference in New Issue
Block a user