-
File I/O Read and Check
Hi, I need help with reading and checking from a binary file. I want to read until a i reach a certin byte. Heres an example...
File:
...291....09...../...0927.. [ect]
EOF
I want to read till the '/' and leave the pointer at that position.
Can anyone help me?
Thanks, ~rab
-
use fgetc() in a loop -- it returns only 1 character at a time, then just check each byte read.
actually, since this is c++ board, not C, you should use fstream's get() method.
-
-
Perhaps these might serve as an alternative:
Code:
istream& get (char* s, streamsize n, char delim );
Reads up to the delim in your case '/', but doesn't read it, rather leaves the pointer on it for the next read.
-------------------------------------------------------------------------------------
or
Code:
istream& getline (char* s, streamsize n, char delim );
Reads file up until the delim in your case '/'. The delim is extracted and discarded.