| Description
This example uses the
fprintf function to write formatted
file output . This example requires
you to create a blank file called
website.txt . In this case on your
d: drive .
Code
#include <stdio.h>
int main()
{
FILE *fp;
int rating = 9;
if (fp = fopen("d:/website.txt",
"w"))
{
fprintf(fp, "Website: Programmershelp\n");
fprintf(fp, "Topic: computer
programming\n");
fprintf(fp, "Rating out of 10
: %d \n",rating );
fclose(fp);
}
else
printf("Error opening d:/website.txt\n");
return 0;
}
Information
tested using LCC Win
32
|