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:
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?
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:And a code
main.mjs:After calling
node main.mjs < data.txtIt results in infinite output:
As the title, is there any way to detect that?