You probably need to read the input as a single line then parse it youself. You have:
while(file>>index>>attribute>>opr>>value){...
since
attribute
is of type
string,
file>>attribute
will read up to the next delimiter character, which is normally a char of type
space
e.g. space, tab, new-line, etc. If your input is
1 height<200.0
2 width<400.0
3 depth<150.0
then, on the first read:
index = 1
attribute = "height<200.0"
opr = '2'
value = 0.0
and the file input pointer will be at the beginning of 'width' on line 2. The next attempt to read will fail to read in anything, since 'w' is not a digit, and cannot be converted to an int.
You can use
getline()
to read in a single line from the file, then, depending on how complex the input strings might possibly get, break down your input string, perhaps with
find_first_of()
or
find_first_not_of
or maybe look into regex classes to help parse the string.