Question:

C++ perform file I/O ?

by  |  earlier

0 LIKES UnLike

I know you can use a stream...but what are some other ways?

 Tags:

   Report

1 ANSWERS


  1. I only use the C subset, which requires

    #include <stdio.h>

    and either open() or fopen().  (The only time I use open is for a network socket, which is an integer, because the functions that use a file handle (pointer: FILE *fp;) are analogous to those that for stdin and stdout, e.g., fprintf().

    For binary files, where you want to read or write a block of memory at a time, there's read() or fread() and write() or fwrite().  It never hurts to add a b after the open mode for binary I/O, but only Windows is flaky enough to require it, because their newline still includes a carriage return.

You're reading: C++ perform file I/O ?

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions