![]() |
![]() |
![]() |
![]() |
![]() |
|
Once you open a file for output, you must switch from printf to
fprintf, an acronym for file print field.
The fprintf function takes an additional argument, a file pointer,
and writes to the file associated with the file pointer instead of to your
screen. Thus, the following statement tells C to write a result into the
file identified by the analysis_target pointer:
fprintf (analysis_target,
"The total value of the %i trades is %f.\n",
limit, sum);