C using fopen to open any file name10/24/2022 you close the file), you will keep using an invalid pointer reference as a key unless you also remove the file from the map. Second, if for some reason you deallocate the file handle (i.e. It comes from some memory allocation within the sdtio library, and you have no control over it. The operations that are allowed on the stream and how these are performed are defined by the mode parameter. For one thing, the pointer is just like a random number to you. FILE fopen ( const char filename, const char mode ) Open file Opens the file whose name is specified in the parameter filename and associates it with a stream that can be identified in future operations by the FILE pointer returned. However, it is pretty dangerous to do so. You could use a FILE *, though, since any pointer can be used as a map key. the FILE class does not implement the necessary comparison operator.it would not make any sense to use an unknown structure of an unknown size whose lifetime you have no direct control of as a key. C USING FOPEN TO OPEN ANY FILE NAME DRIVERSeeking back and forth like crazy between two different parts of a big file could eventually force the disk driver to wobble between two physical parts of the disk, reducing your I/O performance dramatically (unless the disk is a non-seeking device like an SSD). This is one more reason among thousands to check system calls, by the way.Īssuming the second call succeeded you can,for instance, seek to a given position with pFile1 while you read from another with pFile2.Īs a side note, since you will eventually access the same physical disk, it is rarely a good idea to do so unless you know exactly what you're doing.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |