here's the code:
Code:
#include<stdio.h>
#include<conio.h>
void main(void)
{
FILE *fp;
char c;
long i=0L;
clrscr();
printf("Enter the characters now:");
fp=fopen("fseek.txt","w");
while((c=getchar())!=EOF)
{
putc(c,fp);
putc(' ',fp);
}
printf("\nThe number of characters written in file is:%d",ftell(fp));
printf("\nFile written successfully");
fclose(fp);
printf("\n Now opening file for reading every fifth character from starting of file:");
fp=fopen("fseek.txt","r");
if(fp==NULL)
printf("Opening file failed:Error");
else
{
while((c=getc(fp))!=EOF)
{
//printf("%c",c);
fseek(fp,i,0);
i=i+5L;
printf("\nThe character %c is at position %d",c,ftell(fp));
}
}
fclose(fp);
getch();
}
any help would be appreciated , I think i'm missing just something but everything else works fine......
Thanks in advance
