__stdin.d(2): Error: found End of File when expecting }
ag0aep6g
anonymous at example.com
Wed Jul 17 20:02:51 UTC 2019
On 17.07.19 21:05, Andre Pany wrote:
> ```
> #!/bin/bash
>
> text="
> import std;
>
> void main()
> {
> while(true)
> {
> string enemy1 = readln().strip;
> int dist1 = to!int(readln().strip);
>
> string enemy2 = readln().strip;
> int dist2 = to!int(readln().strip);
>
> // Write an action using writeln()
> writeln(dist1 > dist2 ? enemy2 : enemy1);
> // Enter the code here
> }
> }"
>
> curl -fsS https://dlang.org/install.sh | bash -s dmd-2.087.0
> source ~/dlang/dmd-2.087.0/activate
> echo $text | dmd -
> ```
>
> what is here wrong?
Check out what `echo $text` prints:
----
import std; void main() { while(true) { string enemy1 = readln().strip;
int dist1 = to!int(readln().strip); string enemy2 = readln().strip; int
dist2 = to!int(readln().strip); // Write an action using writeln()
writeln(dist1 > dist2 ? enemy2 : enemy1); // Enter the code here } }
----
Note that it's all on one line. And remember that a "//"-style comment
spans the rest of the line.
That's right. Everything after the first "//" is now part of the
comment, all the way to the last closing brace. Obviously, that's not
valid code anymore.
Try using double quotes around $text:
echo "$text" | dmd -
More information about the Digitalmars-d-learn
mailing list