954,224 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Is ifs is a member function of ifstream class

Hi all,

can anyone tell me whether ifs function is a member function of ifstream.

in the statements below the ifs has been used like ........

ifstream ifs( g_pSystemEnvironment->GetTotAlmCountFileName() );

ifs >> m_nNoOfTotalAlarm;

i am not able to understand the code. could anyone help me out of it.

Thanx in advance.

psk
Newbie Poster
1 post since Jul 2004
Reputation Points: 10
Solved Threads: 0
 

look at this example ...

#include <fstream>            • <fstream> header file
using namespace std;         – Use ifstream for input
int main()                         – Use ofstream for output
{
ifstream ifs;                      
ifs.open(“in.txt);              • Other methods 
ofstream ofs(“out.txt);     – open, is_open, close    
if (ifs.is_open() &&            – getline
ofs.is_open()){                – seekg, seekp  
int i;                              • File modes
ifs >> i;                          – in, out, ate, app, trunc, binary
ofs << i; 
}
ifs.close();
 ofs.close();
return 0;
}

--------------------------------------------------------------------------------

#include <iostream>         • <sstream> header file
#include <fstream>          – Use istringstream for input
#include <sstream>          – Use ostringstream for output
using namespace std;       
int main() {                      • Useful for scanning input
ifstream ifs(“in.txt);          – Get a line from file into string
if (ifs.is_open())                – Wrap string in a stream
{string line1, word1;          – Pull words off the stream
getline(ifs, line1);              • Useful for formatting output
istringstream iss(line1);      – Use string as format buffer
iss >> word1;                   – Wrap string in a stream
cout << word1 << endl;     – Push formatted values into stream
}                                    – Output formatted string to file
return 0;
}
meabed
Junior Poster
Team Colleague
139 posts since May 2004
Reputation Points: 55
Solved Threads: 3
 

can anyone tell me whether ifs function is a member function of ifstream.

ifstream ifs( g_pSystemEnvironment->GetTotAlmCountFileName() );
i am not able to understand the code. could anyone help me out of it.

Hereifs is not a function. It is an object of type ifstream. It is being instantiated using a parameterized constructor (passing the result of the g_pSystemEnvironment->GetTotAlmCountFileName function as the parameter) instead of the default constructor.

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You