When writing code, itβs c/c++pretty convenient to use freopen () . See the following code snippet -
int main(){
int n1, n2, result;
freopen("input.txt", "rb", stdin);
freopen("output.txt", "wb", sdtout);
while(scanf("%d %d", &n1, &n2)==2 && n1>0 &&n2>0){
...
...
...
printf("%d\n", result);
}
return 0;
}
Using freopen()this way is very useful when we are trying to debug / test a small console application. We can put the input sample into the file 'input.txt' once and reuse it every time instead of manually entering the input in the terminal / console. And in the same way, we can print the output in the file 'output.txt .
java, . - / , . / . - ?