In C I can read and write files using scanf
and printf
by piping them as follows:
freopen ("input.txt", "r", stdin);
freopen ("output.txt", "w", stdout);
In Java you can do the same with
System.setIn
And friends.
This it very convenient if you need to swap between using a file and stdin/stdout often, and if to keep your code free from file pointers.
Does Go have something similar?