How can i read in data in different functions without losing the stream's place in the file. i.e function a and function b both open a data stream to read in first and last names from a file. however function b reads in the first name as well rather than the last name because it loses it's place as i closed the stream in function a and re-opened the stream in function b. would passing an open stream to other functions prevent this? if not i guess i'll doddle how to implement seekg and tellg

Pass the open stream to each function as a parameter.

void func1(ifstream& in)
{

}

void func2(ifstream& in)
{

}

int main()
{
   ifstream in("myfile.txt");
   funct1(in);
   funct2(in);

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.