/* Copyright (c) 2001-2004 by SoftIntegration, Inc. All Rights Reserved */
/* a sample program that uses the fgetpos() to read the fourth
   character from a file. */ 
#include <stdio.h>
#include <stdlib.h>

int main() {
    FILE *stream;
    fpos_t pos;
    char ch;
    long int offset = 3; 
    /* open file for reading */
    if((stream = fopen("fgetpos.c","r")) == NULL){ 
        printf("cannot open file\n");
        exit(1);
    }
    fseek(stream, offset ,SEEK_SET);
    fgetpos(stream,&pos);
    fsetpos(stream,&pos);
    fread(&ch,sizeof(char),1,stream);   //read a character
    printf("The current character in file is '%c'\n",ch);
    fclose(stream);
}
