Sponsored Content
Full Discussion: file pointer
Top Forums Programming file pointer Post 99641 by jim mcnamara on Monday 20th of February 2006 09:50:33 AM
Old 02-20-2006
Code:
FILE *in;  
is a struct that is used by stdio.h routines to access files, called a stream, they ultimately point to a file descriptor number:
int fd=open(....);
which is created by the open call.

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.
 

10 More Discussions You Might Find Interesting

1. Programming

pointer

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)
Discussion started by: sarwan
1 Replies

2. Programming

file pointer

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)
Discussion started by: bankpro
3 Replies

3. UNIX for Dummies Questions & Answers

confusion (file pointer and file descripter)

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)
Discussion started by: johnray31
1 Replies

4. Programming

why we never delete a pointer twice

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)
Discussion started by: amitpansuria
2 Replies

5. Programming

far pointer

what is far pointer in C (1 Reply)
Discussion started by: useless79
1 Replies

6. Shell Programming and Scripting

Perl how to move pointer to previous line in a txt file?

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)
Discussion started by: tqlam
5 Replies

7. Programming

how to move file pointer to a particular line in c

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)
Discussion started by: user_prady
7 Replies

8. Programming

pass a pointer-to-pointer, or return a pointer?

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)
Discussion started by: aaronwong
11 Replies

9. UNIX for Dummies Questions & Answers

Difference between file descriptor and file pointer

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)
Discussion started by: jimmyuk
10 Replies

10. Programming

question about int arrays and file pointer arrays

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
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)
All times are GMT -4. The time now is 04:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy