-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
I'm a newbie, so if this question is dumb, I'm sorry.
I don't know how to detect if it's the end of the input. For example, if I have a file called data.txt:
2 1 1
1 2 2
2 2 3
1 2 5
And a code main.mjs:
import { default as scanf, sscanf } from "scanf";
let a, b, c;
while(([a, b, c] = scanf("%d %d %d"))) { // don't know when to stop
console.log(a, b, c);
}After calling node main.mjs < data.txt
It results in infinite output:
2 1 1
1 2 2
2 2 3
1 2 5
2 1 1
1 2 2
2 2 3
1 2 5
2 1 1
1 2 2
2 2 3
1 2 5
// ... omitted
As the title, is there any way to detect that?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels