Why doesn't this piece of code work?

SvGaming sven.kovac1 at outlook.com
Sun May 15 12:19:22 UTC 2022


On Sunday, 15 May 2022 at 12:13:14 UTC, kdevel wrote:
> On Sunday, 15 May 2022 at 11:10:41 UTC, SvGaming wrote:
>> [...]
>
> ```
> import std.stdio;
> import std.process;
>
> int main ()
> {
>    writeln("Here is a list of your mounted drives: ");
>    auto mounts = executeShell("cat /proc/mounts | grep media");
>    writeln(mounts.output);
>    writef("Type the path to your USB drive: ");
>    string cont = readln;
>    writeln(cont); // there was no variable named "a"
>    writeln("A file selection menu will now appear so you can 
> select an ISO to write.");
> //   auto seliso = executeShell("zenity --file-selection");
> //   writeln(seliso.output);
>    return 0;
> }
> ```
>
> This code runs as expected.

Strange. It does not for me. I even tried different compilers.
It simply does not ask for user input here where it is supposed 
to:
```d
writef("Type the path to your USB drive: ");
string cont = readln;
writeln(cont); // there was no variable named "a"
```


More information about the Digitalmars-d-learn mailing list