file pointer


 
Thread Tools Search this Thread
Top Forums Programming file pointer
# 1  
Old 02-20-2006
file pointer

what is the difference between a file pointer and a file descriptor.
# 2  
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. Programming

far pointer

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

7. 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

8. 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

9. 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

10. 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
Login or Register to Ask a Question