Îļþ¶Á×Ö·û´®º¯Êýʱ£¬ËÄÜ˵˵ÆäËû·½·¨
#include <stdio.h>#include <stdlib.h>
void main()
{
FILE *fp;
int i;
char s[11];
if((fp=fopen("d:\\1.txt","w"))==NULL)
{printf("Can not open file!\n");exit(0);}
for(i=0;i<6;i++)
{
gets(s);
fputs(s,fp);
}
fclose(fp);
if((fp=fopen("d:\\1.txt","r"))==NULL)
{printf("Can not open file!\n");exit(0);}
for(i=0;i<3;i++)
fgets(s,11,fp); /*Õâ¸öµØ·½3´ÎÖظ´¶Á×Ö·û´®£¬ºÜÀÛ׸£¬Äܲ»ÄÜÈÃfpÖ¸ÏòµÄµÚÈý×é×Ö·û´®Ö±½Ó¶Á¸øs*/
puts(s);
fclose(fp);
getch();
}
code¹¦ÄÜÊÇ´Ó¼üÅÌÊäÈë6×鳤¶ÈΪ10µÄ×Ö·û´®£¬´æÈëd:\1.txt¡£È»ºóÊä³öµÚÈý×é×Ö·û´®¡£