File Modes In C++
Mode | Description |
ios::app | If FileName is a new file, data is written to it. If FileName already exists and contains data, then it is opened, the compiler goes to the end of the file and adds the new data to it. |
ios::ate | If FileName is a new file, data is written to it and subsequently added to the end of the file. If FileName already exists and contains data, then it is opened and data is written in the current position. |
ios::in | If FileName is a new file, then it gets created fine as an empty file. If FileName already exists, then it is opened and its content is made available for processing |
ios::out | If FileName is a new file, then it gets created fine as an empty file. Once/Since it gets created empty, you can write data to it. If FileName already exists, then it is opened, its content is destroyed, and the file becomes as new. Therefore you can create new data to write to it. Then, if you save the file, which is the main purpose of this mode, the new content is saved it.*This operation is typically used when you want to save a file |
ios::trunc | If FileName already exists, its content is destroyed and the file becomes as new |
ios::nocreate | If FileName is a new file, the operation fails because it cannot create a new file. If FileName already exists, then it is opened and its content is made available for processing |
ios::noreplace | If FileName is a new file, then it gets created fine. If FileName already exists and you try to open it, this operation would fail because it cannot create a file of the same name in the same location. |
0 comments:
Post a Comment