27 Aralık 2016 Salı

C++ Dosya Okuma Yazma İşlemleri

ofstreamThis data type represents the output file stream and is used to create files and to write information to files.
ifstreamThis data type represents the input file stream and is used to read information from files.
fstreamThis data type represents the file stream generally, and has the capabilities of both ofstream and ifstream which means it can create files, write information to files, and read information from files.
ios::appAppend mode. All output to that file to be appended to the end.
ios::ateOpen a file for output and move the read/write control to the end of the file.
ios::inOpen a file for reading.
ios::outOpen a file for writing.
ios::truncIf the file already exists, its contents will be truncated before opening the file.





Dosya içinde Gezebilmek için ;


 These member functions are seekg ("seek get") for istream and seekp ("seek put") for ostream.


The seek direction can be ios::beg (the default) for positioning relative to the beginning of a stream, ios::cur for positioning relative to the current position in a stream or ios::end for positioning relative to the end of a stream.





// position to the nth byte of fileObject (assumes ios::beg)
fileObject.seekg( n );

// position n bytes forward in fileObject
fileObject.seekg( n, ios::cur );

// position n bytes back from end of fileObject
fileObject.seekg( n, ios::end );

// position at end of fileObject
fileObject.seekg( 0, ios::end );

Share: