a question about ftell function

X

xcm

i find ftell's return value is not the current pointer of the stream buf

I know it is the file pointer. but where is it? who maintain it?

please Help me.
 
J

Jack Klein

i find ftell's return value is not the current pointer of the stream buf

The value returned by the ftell() function is the current value of the
file position indicator for a stream. If the stream is binary (that
is opened with 'b' in the mode string), then it represents the number
of characters from the beginning of the file. If the stream was
opened in text mode, it contains unspecified information.

There is no defined connection at all between the file position
indicator and a buffer associated with the stream by the setbuf() or
setvbuf() functions. Why do you think that there should be?
I know it is the file pointer. but where is it? who maintain it?

Use of the term "file pointer" is very confusing here, as most people
would use it for an object of type 'FILE *' returned by fopen and used
by subsequent calls to file handling functions.
please Help me.

Help you what? What is it that you think you need to know about the
file position indicator, returned by ftell()? What are you trying to
do with it?
 
G

glen herrmannsfeldt

Jack said:
comp.lang.c:
The value returned by the ftell() function is the current value of the
file position indicator for a stream. If the stream is binary (that
is opened with 'b' in the mode string), then it represents the number
of characters from the beginning of the file. If the stream was
opened in text mode, it contains unspecified information.

Unless the processor/OS doesn't supply the required information.

See what IBM does on MVS and VM, especially for variable length
records, but I believe even for fixed length records.

http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/edcguid2/5.1.6.1

http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/edcguid2/5.2.2

-- glen
 
L

Lawrence Kirby

Unless the processor/OS doesn't supply the required information.

As long as fseek() and ftell() fail (i.e. do nothing and return 0 and -1
respectively) when they cannot otherwise conform to the standard's
specification that is fine.

Lawrence
 
S

Scott J. McCaughrin

: i find ftell's return value is not the current pointer of the stream buf

: I know it is the file pointer. but where is it? who maintain it?

: please Help me.

long ftell(FILE* fp) returns the current "file position indicator", i.e.,
the offset of the current byte position in the file referenced by 'fp'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top