Hi,
I'm trying to read in a section of a line from a file, and to compare that to an integer. I know that the piece I'm reading in will be 3 numbers (xxx) and be followed by a space. It will also be the first entry on each line (I know this as I did the output).
What I need to be able to do is grab that number and compare it to an int to see if this is the line that I need.
But I'm having a bear of a time. From what I can tell, I can't compare the string to an int, I can't convert the string to an int to compare. And I've not had any luck trying it with a C-Style string. And help would be greatly appreciated.
Thanks
David
string number;
string line;
char temp;
int index;
int compare;
bool success;
ifstream in("records.txt");
ofstream out("outfile.txt");
if(in.is_open()){
while( getline(in,line) ){
index = line.find_first_of(" ",0,256);
number = line.substr(0,index);
temp = number;
compare = atoi(temp);
if(temp != registrationID){
out << line << "\n";
}