// 261.c
#include<stdio.h>
void main()
{
FILE *fp,*fq;
char a[100],name[20],x;
gets(name);
fp=fopen(name,"r");
fgets(a,100,fp);
printf("this file in's neirong is:");
puts(a);
gets(name);
fq=fopen(name,"w");
rewind(fp);
while((x=fgetc(fp))!=EOF)
{
fputc(x,fq);
}
fclose(fp);
fclose(fq);
getch();
}
// 262.c
#include<stdio.h>
void main()
{
FILE *fp;
char a[200];
fp=fopen("abc.txt","r");
fseek(fp,4,0);
fgets(a,15,fp);
puts(a);
getch();
}
// 263.c
#include<stdio.h>
void main()
{
FILE *fp;
char x;
fp=fopen("abc.txt","r");
do
{
while((x=fgetc(fp))!='\n'&&x!=EOF)
putchar(x);
printf("\n");
while((x=fgetc(fp))!='\n'&&x!=EOF);
}while(x!=EOF);
getch();
}
// 264.c
#include<stdio.h>
void main()
{
FILE *fp;
char a[100];
int n=0;
fp=fopen("abc.txt","r");
while(fgetc(fp)!='\n')n++;
rewind(fp);
while(1)
{
fgets(a,n+1,fp);
puts(a);
fseek(fp,n+3,SEEK_CUR);
if(fgetc(fp)==EOF)break;
}
getch();
}
// 265.c
#include<stdio.h>
void main()
{
FILE *fp;
fp=fopen("abc.txt","r");
fgetc(fp);
fgetc(fp);
fgetc(fp);
printf("%d",ftell(fp));
getch();
}
// lianbiao.h
#include<malloc.h>
struct node
{
int num;
struct node *next;
};
void putfun(struct node *head)
{
while(head!=NULL)
{
printf("%3d",head->num);
head=head->next;
}
}
struct node *fun(int n)
{
struct node *head,*p1,*p2;
int i=0;
head=p1=p2=(struct node *)malloc(sizeof(struct node));
scanf("%d",&head->num);
i++;
while(i<n)
{
p2=p1;
p1=(struct node *)malloc(sizeof(struct node));
scanf("%d",&p1->num);
p2->next=p1;
i++;
}
p1->next=NULL;
return head;
}
struct node *fxfun(struct node *head)
{
struct node *p1,*p2,*p3,*m;
if(head->next==NULL)return head;
m=NULL;
p2=head;
p1=p2->next;
p3=p1->next;
while(p3!=NULL)
{
p2->next=m;
p1->next=p2;
m=p2;
p2=p1;
p1=p3;
p3=p3->next;
}
p2->next=m;
p1->next=p2;
return p1;
}
struct node *delfun(struct node *p,int n)
{
struct node *head,*m;
head=m=p;
if(p->num==n){head=head->next;free(p);return head;}
while(p!=NULL&&p->num!=n)
{
m=p;
p=p->next;
}
if(p!=NULL)m->next=p->next;
free(p);
return head;
}
struct node *insfun(struct node *p,int n)
{
struct node *head=p,*m,*q;
q=(struct node *)malloc(sizeof(struct node));
q->num=n;
if(n<=head->num)
{
q->next=head;
head=q;
return head;
}
while(p->num<n&&p!=NULL)
{
m=p;
p=p->next;
}
q->next=p;
m->next=q;
return head;
}