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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing streams

Status
Not open for further replies.

Sherak

Programmer
Sep 1, 2003
83
GB
I am reading from a file using a stream, and wish to pass the stream into a function I call, I tried this but it doesnt work, any ideas?... thx in adv
..................................
fstream File;
char x;

File.open("file.txt", ios::in);

while(!File.eof())
{
File >> x;
if(x == "a"){GetLine(File);}
}
.................................

*/declaration/*
void GetLine(fstream InFile);
.................................

*/implementation/*

void GetLine(fstream InFile)
{
char Y;

InFile >> Y;

}

 
Just off the top of my head, try
Code:
GetLine(fstream* InFile);
.


James P. Cottingham

There's no place like 127.0.0.1.
There's no place like 127.0.0.1.
 
Yeah nearly, you can tell it was the end of the day when I was trying to do it :-S... It is as follows (basic pointer passing rules really)

..................................
fstream File;
char x;

File.open("file.txt", ios::in);

while(!File.eof())
{
File >> x;
if(x == "a"){GetLine(&File);}
}
.................................

*/declaration/*
void GetLine(fstream *InFile);
.................................

*/implementation/*

void GetLine(fstream *InFile)
{
char Y;

*InFile >> Y;

}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top