Why doesn't this piece of code work?
kdevel
kdevel at vogtner.de
Sun May 15 20:06:20 UTC 2022
On Sunday, 15 May 2022 at 15:27:32 UTC, SvGaming wrote:
[...]
> It works if that code is the main function. But in the full
> program that is only one of the functions and is not the main
> function.
Until you post your full programm ideally in a reduced form [1]
everybody who is willing to help must guess wildly what the
unposted parts of your program does and how it may cause the read
to be seemingly skipped.
```
import std.stdio;
import std.process;
void foo ()
{
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);
}
int main ()
{
foo;
return 0;
}
```
Also works as expected.
What does `strace` report? And what compiler/version do you use?
[1] https://stackoverflow.com/help/minimal-reproducible-example
More information about the Digitalmars-d-learn
mailing list