Im doing some string searching and I keep getting this error can some one help.
################################################## #################
#include <fstream.h> //for IO
#include <stdio.h>
#include <string>
#include <string.h>
#include <stdlib.h>
int main()
{
//Declare our input file name
char filename[] = "fingers.txt";
char ch_check; //checks for eof
string line;
int index; //index of where "Name: " is found
string INFO[50]; //our array for stroring the info
string stringA = "Name: ";
int i = 0; //index for number of entries in to our array
ifstream INFILE;
INFILE.open(filename);
if(INFILE.fail())
{
cout << "Couldn't open the input file: " << filename <<endl;
cout << "Please make sure that it exists and you have permissions to read it." <<endl;
exit(1);
}else{
cout << "The file " << filename << " was opened successfully" <<endl;
}
/*
while((ch_check = INFILE.peek()) != EOF)
{
INFILE.get(character); //input from our file stream
cout << character;
}
*/
//We will get the name of each person. We look for the word "Login:", this line contains the user information that we want.
int MAXCHARACTERS = 50;//the maximum number of characters to search in a line
while((ch_check == INFILE.peek()) != EOF)
{
//Search for the word "Login"
INFILE.getline(line,MAXCHARACTERS,'\n'); //search each line until you reach MAXCHARACTERS or reach a newline.
index = line.find(stringA); //look for stringA in 'line'
if(index != ios::npos) //if we find the string
{
INFO[i] = line.substr(index + 6, line.find("\n");
i += 1;
}
}
for(int j = 0; j < 50; j++)
{
cout << INFO[j];
}
INFILE.close();
return 0;
}
################################################
The error says
no matching function for calll to 'ifstream::getline (string &,int &,ch &'
Thanx,


);
Reply With Quote
Bookmarks