Normally a file pointer is NOT a "stream". A file pointer is defined as the current position in the file maintained for a given file descriptor - the OS keeps track of it. What I think you meant by file pointer is the "stream" above.
ftell() returns the position of the file pointer relative to the start of the file.
void main()
{
int a={1,2,3,4,5,6,7,8,9,10};
int *p=a;
int *q=&a;
cout<<q-p+1<<endl;
}
The output is 10, how?
if we give cout<<q it will print the address, value won't print....
if we give cout<<p it will print the address, value won't print....
p has the base addr; q... (1 Reply)
hi all:
bankpro again,
i want to open a file and close it after an hour (i.e open and close the file ptr)
In the mean time i will be executing my jobs using the shell (CommandInterpreter).
plz help... :cool: (3 Replies)
Hi everybody,
i am newbie to unix and confused with file pointers and file descripters.
could anyone help me to clear my doubts ..
when we call unix system calls to create a file then we are dealing wih file descripters
i think file descripters are also normals file as stored inhard disks... (1 Reply)
can u tell me the reson that why we should not delete a pointer twice.?
if we delete ponter twice then what happen and why this happen
Regards,
Amit (2 Replies)
I have a text file that has blocks of text. Each block starts with ### and ends with End_###.
I wrote a perl script to search a string from line 2 (ignore any line starts with ###) of each block
if matched, need to print that whole block. According to the input file in below, it will print... (5 Replies)
Hello experts,
I ve a text file I want to go to particular line . what is the best way to do this in c ?
I am tried as follows
fseek ( fh, pos, SEEK_SET);
but this functions moves the file pointer according to a number of bytes. Unfortunately I don't know the exact byte... (7 Replies)
If one wants to get a start address of a array or a string or a block of memory via a function, there are at least two methods to achieve it:
(1) one is to pass a pointer-to-pointer parameter, like:
int my_malloc(int size, char **pmem)
{
*pmem=(char *)malloc(size);
if(*pmem==NULL)... (11 Replies)
hi....,
can anyone tell me what is the exact difference between file descriptor and file pointer...... and why file descriptor takes integer value???:confused: (10 Replies)
if i declare both but don't input any variables what values will the int array and file pointer array have on default, and if i want to reset any of the elements of both arrays to default, should i just set it to 0 or NULL or what? (1 Reply)
Discussion started by: omega666
1 Replies
LEARN ABOUT SUNOS
ftell
ftell(3C) Standard C Library Functions ftell(3C)NAME
ftell, ftello - return a file offset in a stream
SYNOPSIS
#include <stdio.h>
long ftell(FILE *stream);
off_t ftello(FILE *stream);
DESCRIPTION
The ftell() function obtains the current value of the file-position indicator for the stream pointed to by stream. The ftello() function is
identical to ftell() except for the return type.
RETURN VALUES
Upon successful completion, the ftell() and ftello() functions return the current value of the file-position indicator for the stream mea-
sured in bytes from the beginning of the file. Otherwise, they return -1 and sets errno to indicate the error.
ERRORS
The ftell() and ftello() functions will fail if:
EBADF The file descriptor underlying stream is not an open file descriptor.
ESPIPE The file descriptor underlying stream is associated with a pipe, a FIFO, or a socket.
The ftell() function will fail if:
EOVERFLOW The current file offset cannot be represented correctly in an object of type long.
The ftello() function will fail if:
EOVERFLOW The current file offset cannot be represented correctly in an object of type off_t.
USAGE
The ftello() function has a transitional interface for 64-bit file offsets. See lf64(5).
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
SEE ALSO lseek(2), fopen(3C), fseek(3C), attributes(5), , standards(5), lf64(5)SunOS 5.10 24 Jul 2002 ftell(3C)