[- Disclaimer -]
아래 내용은 정보보안 공부 목적으로 작성된 것이나, 이를 토대로 허가되지 않은 대상에 실습을 진행할 경우 해킹 시도로 간주하여 법적 처벌을 받을 수 있음을 알려 드립니다.
ftell()
✦ <stdio.h>
✦ 현재 파일 Stream 포인터 위치 값 출력
✦ Parameter에 전달되는 Argument
✧ 파일 Stream 포인터 자체 주소
✦ Retrun 값
✧ 성공
→ 현재 파일 Stream 포인터 offset
✧ 실패
→ -1
long ftell(FILE *stream);
Plain Text
복사
test.txt에 "ABC"가 적혀 있을 경우 - Ex)
#include <stdio.h>
int main(void) {
FILE *fp = NULL;
fp = fopen("test.txt", "r");
if (fp != NULL) {
int c = 0;
while (c != EOF) {
c = getc(fp);
printf("%c\n", c);
printf("ftell: %ld\n\n", ftell(fp));
}
}
fclose(fp);
fp = NULL;
}
Plain Text
복사
A
ftell: 1
B
ftell: 2
C
ftell: 3
ftell: 3
--------------------------------
Process exited after 0.2798 seconds with return value 0
계속하려면 아무 키나 누르십시오 . . .
Plain Text
복사



