File
/*
===============================================================
Title: Enter the height data of 10 basketball players (cm) Save to D disk File High.txt:
0 indicates that the input is complete.
x= 180 182 179 185 191 178 184 185 183 192
===============================================================
*/
#include <stdio.h>
void Main ()
{
FILE *FP;
int x;
Fp=fopen ("D:\\high.txt", "w");
if (fp==null)
printf ("File open failed!") \ n ");
Else
{
while (x!=0)
{
scanf ("%d", &x);
fprintf (FP, "%4d", X);
}
Fclose (FP);
}
}
/*
========================================================================
Evaluation:
fprintf (FP, "%d", X), while FSCANF has &, such as (FP, "%d", &x);
The input problem of an array is simply a different control statement.
========================================================================
*/
C language File operation 06--Write data to text file 0 stop