Hi,
How can I use iostream library in c++ to copy a file from i th byte
to an output file?
Create a 'std::ifstream' object using constructor
parameters of your input file name and binary mode.
Check the stream state to ensure it successfully opened.
Create a 'std:
fstream' object using constructor
parameters of your output file name and binary mode.
Check the stream state to ensure it successfully opened.
Read characters from the input stream (e.g. using the
'get()' member function), counting how many characters
have been read, until you reach the 'ith'.
Read a character from the input stream.
Write that character to the output stream (e.g. with the
'put()' member function).
After every read and write operation, check the stream
state to determine if the operation succeeded. When
the input stream indicates a fail state, either there
was an error, or you've reached end of file (determine
the difference with the 'eof()' member function.)
Close both files (or cause them to be automatically closed
by exiting the scope where they're defined.
The 'std::ifstream' and 'std:
fstream' are declared by
standard header <fstream>.
-Mike