The above code given by "DeadlyGhos7" tells you how to open a file. But you have to finish the code by referring to other examples of FILE programming in C.

Command redirection will redirect the output of a program(which will be printed on screen) to any other file that we want.