In c++ what does this piece of code do?

In lot of editorials i have seen this

freopen("input.txt", "r", stdin);

freopen("output.txt", "w", stdout);

freopen("error.txt", "w", stderr);


It is for writing input output on file.

but how it is beneficial ,as code will accept input and provide output without this also .
i want to know how it will help us in competitive programming with online compiler

This useful when you are debugging ie you want to see output for large no of inputs

sorry but can you please explain how can i do it
actually i am new to programming world and i want to use this

Read about file handling