Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Pointer

Status
Not open for further replies.

raghu75

Programmer
Nov 21, 2000
66
IN
All,
I have a file pointer and i need to keep track of it in two functions to which i have passed it.My problem is like below.
void temp(file* fp)
{
temp1(fp);
}
void temp1(file* fp)
{
...
...
i am reading a line of the file here
}
i need to keep track of the file pointer in both the funcitons...how should i do it...
advance thanks

 
I dont think i understand fully what you are trying to do. If this is not multi-threaded then it looks like your doing what you want to. By passing a pointer, you are, in essence, passing the actual pointer to the file. Both functions receive the same pointer. If fp when declared had memory address 999 then the fp received by temp and temp1 both receive a pointer to memory address 999. I am not sure if this is what you were looking for so if it is not please let me know where I went wrong.

Matt
 
It will work so far as you are not closing and re-opening file in your temp1() function. As I know read function do not change file pointer. If you want to close and re-open file in temp1() use double pointer.
 
In C programming style it will look like:

void temp(file** fp)
{
temp1(*fp);
}
void temp1(file* fp)
{
...
...
i am reading a line of the file here
} John Fill
1c.bmp


ivfmd@mail.md
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top