>
" to redirect the
output of a program to a file:
myprogram > output.txtRemember your program will still be expecting input from the keyboard.
#include <stdio.h> FILE fs; /* declare the stream fs */ fs=fopen("output.txt","w"); /* open the file */ fprintf(fs," %f %f",x0,y0); /* write x0 and y0 to the file */ fclose(fp);
#include <fstream.h> ofstream fs; /* declaration of stream fs */ fs.open("file.out"); /* opens file "file.out" */ fs << "Hello, file" << endl; /* now write to the file */ fs.close(); /* close file */