Rewind

    C / LINUX ftell(3) fseek(3) rewind(3)

    #include #include int main(void){ char *fname = "ssu_test.txt"; FILE *fp; long position; int character; if ((fp=fopen(fname,"r"))==NULL){ fprintf(stderr, "fopen error for %s\n",fname); exit(1); } printf("Input number>>"); scanf("%ld",&position); fseek(fp,position-1,SEEK_SET); character=getc(fp); printf("%ldth character -> %c\n",position,character); exit(0); } 함수 기능 ftell 파일 스트림의 현재 오프셋 위치가 파일의 시..