S
stevenruiz
Hi Everyone,
The Strings.h has the function Get_Line which is defined and the error
is shown below:
Strings.h:
void get_line( istream & );
#include "Strings.h"
#include <fstream.h>
int main( int argc, char** argv)
{
fstream File;
Strings End_Of_Line;
File.open("/users/netgrps/sf305/test.txt", ios::in);
Strings output = "", Stored_Message="", Line(End_Of_Line);
int num_of_hits=0;
while( ! File.eof())
{
if(Line.findStr("Stat:") != 0)
{
num_of_hits++;
if(num_of_hits == 2)
break;
}
if(num_of_hits == 1)
Stored_Message += Line;
Line.get_line(File);
End_Of_Line = Line;
}
cout << Stored_Message << endl;
}
I opened the library that Strings.h is compiled into with the command
"nm -print" and the method exists. Any idea what may be the problem?
The problem that I have involves program that searches for a certain string within a file. As seen in the code, I have declared a Strings class which overrides the string class in C++. Inside of this class, it has a function called findStr (replaces the find in string.h) which will return a 0 when it is able to find an occurrence within the file. If not, it will return a -1.
The Strings.h has the function Get_Line which is defined and the error
is shown below:
Strings.h:
void get_line( istream & );
ld: Unresolved:
String::get_line(std::basic_istream <char,
std::char_traits<char>&>)
The code segment follows this structure and does compile:
#include "Strings.h"
#include <fstream.h>
int main( int argc, char** argv)
{
fstream File;
Strings End_Of_Line;
File.open("/users/netgrps/sf305/test.txt", ios::in);
Strings output = "", Stored_Message="", Line(End_Of_Line);
int num_of_hits=0;
while( ! File.eof())
{
if(Line.findStr("Stat:") != 0)
{
num_of_hits++;
if(num_of_hits == 2)
break;
}
if(num_of_hits == 1)
Stored_Message += Line;
Line.get_line(File);
End_Of_Line = Line;
}
cout << Stored_Message << endl;
}
I opened the library that Strings.h is compiled into with the command
"nm -print" and the method exists. Any idea what may be the problem?