EmbLogic's Blog

This is a program to read last n characters from the file.

head    1.1;
access;
symbols;
locks; strict;
comment    @ * @;

1.1
date    2014.03.19.15.00.37;    author emblogic;    state Exp;
branches;
next    ;

desc
@this is a program to read last n chararcter from the file.
@

1.1
log
@Initial revision
@
text
@#include<stdio.h>
#include<string.h>
int main()
{
FILE *f1;
int pos,n;
char ch;
printf(“enter the value of n”);
scanf(“%d”,&n);
f1=fopen(“file3″,”r”);
//getc(f1);
fseek(f1,0,SEEK_END);
fseek(f1,n,SEEK_SET);
pos=ftell(f1);
printf(“position is %d”,pos);
do
{
ch=fgetc(f1);
printf(“%c”,ch);
}
while(ch !=10);

return 0;
}

@

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>