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);
An array of input problems, except that the control statements are different.
========================================================================
*/
Copyright Notice: Bo Main article can be reproduced non-commercial, but please be sure to indicate the source, because the level is limited, inevitably error, in this disclaimer.
C language File operation 06--Write data to text file 0 stop