|
|
|
|
Duoas wrote: |
---|
If it makes a difference whether or not you notice them specifically, then you are stuck using a C style I/O function |
Duoas wrote: |
---|
Those are for specific cases though. Normally, you should just let the usual RAII do it's job. |
std::vector<std::string> parse( std::ifstream file ) ; // the caller does not need the stream any more
|
|
JLBorges wrote: |
---|
Perhaps a whole lot of newbies on this site learnt i/o with files from that tutorial. |
LB wrote: |
---|
We should probably just rewrite the tutorial and have twicker update it. |
Why? Because maybe I feel the need to okay pal? |
Computergeek01 wrote: |
---|
Personally I like to have all of my variable declarations at the top of the function block, I don't think that there is a functional reason that I am aware of, it just drives me crazy to see people creating variables "as they need them". It seems disorganized like they are only thinking of this line and the next instead of the function as a whole. This means that if for some reason I am to query the user for a file name I would initialize the stream at the top of the function block and call 'open()' after obtaining the string. |
but why on earth would there be a potential for an error to occur on closing a file? |
ERRORS The close() function will fail if: EBADF The fildes argument is not a valid file descriptor. EINTR The close() function was interrupted by a signal. ENOLINK The fildes argument is on a remote machine and the link to that machine is no longer active. ENOSPC There was no free space remaining on the device con- taining the file. The close() function may fail if: EIO An I/O error occurred while reading from or writing to the file system. |