void fun(char *filename, STU n)
{ FILE *fp;
/found/
fp = fopen(filename, “rb+”);
/found/
fseek(fp, -(long)sizeof(STU), SEEK_END);
/found/
fwrite(&n, sizeof(STU), 1, fp);
fclose(fp);
}
{ NODE *h=NULL, *p, s;
int i;
/found/
p=(NODE *)malloc(sizeof(NODE));
h=p;
p->next=NULL;
for(i=1; i<=n; i++)
{ s=(NODE )malloc(sizeof(NODE));
s->data=rand()%m; s->next=p->next;
p->next=s; p=p->next;
}
/found/
return h;
}
void main()
{
FILE wf;
char line[N];
int num=0;
printf("Enter a string:\n ");
gets(line);
num=fun(line);
printf(“The number of word is:%d\n\n “,num);
//
wf=fopen(“out.dat”,“w”);
fprintf(wf,”%d”,fun(“a big car”));
fclose(wf);
//
}
————————————————
版权声明:本文为CSDN博主「Nice 2s you.」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_54638312/article/details/118523433