I am making a library to help parse some files, so in a function I created called 'Next_Float' if the found token doesn't completely match a number (say the token is '123.123TEST') it would null terminate the token in the buffer and reset the file pointer (in this case it should move back 4 so that the file pointer is at 'T'). Everything seemed to be working, however, when fseek has reached the end of the line exactly after a float with following characters it moves back the file pointer one more than it should. Am I doing something incorrectly and if not is there any way to get around this or use another method?
fseek Call:
Example Input:Code:fseek(Input, - k + (i - 1), SEEK_CUR);
Example (Debug) Output -- Notice how any token before a newline is fseek-ed too far back:Code:1123.123TESTa 2123.123TESTb 3123.123TESTc 4123.123TESTd 5123.123TESTe 6123.123TESTf 7123.123TESTg 8123.123TESTh 9123.123TESTi
Code:The fseek value: -6. Token to be processed: 1123.123TESTa. Next Token: TESTa The fseek value: -6. Token to be processed: 2123.123TESTb. Next Token: 3TESTb -Next_Line- The fseek value: -6. Token to be processed: 3123.123TESTc. Next Token: TESTc The fseek value: -6. Token to be processed: 4123.123TESTd. Next Token: 3TESTd -Next_Line- The fseek value: -6. Token to be processed: 5123.123TESTe. Next Token: TESTe The fseek value: -6. Token to be processed: 6123.123TESTf. Next Token: TESTf The fseek value: -6. Token to be processed: 7123.123TESTg. Next Token: 3TESTg -Next_Line- The fseek value: -6. Token to be processed: 8123.123TESTh. Next Token: 3TESTh -Next_Line- The fseek value: -6. Token to be processed: 9123.123TESTi. Next Token: 3TESTi -Next_Line-



3Likes
LinkBack URL
About LinkBacks



