Friday, April 17, 2009

FSEEK

#include
void main()
{
FILE *fp;
int n,ch;
clrscr();
/*fp=fopen("s1.txt","w");
if(fp==NULL)
{
printf("file is not create\n");
exit();
}
printf("Enter text and press. to stop\n");
while(c!='.')
{
c=getchar();
fput(c,fp);
}
fclose(fp);*/

fp=fopen("s1.txt","r");
printf("Contents of ur file\n");
while(ch=fgetc(fp)!=EOF)
printf("%c",ch);
printf("How many u wnat to skip\n");
scanf("%d",&n);
fseek(fp,n,SEEK_SET);
printf("Information after %d skip=\n",n);
while(ch=fgetc(fp)!=EOF)
printf("%c",ch);
fclose(fp);
}

No comments: