PDA

View Full Version : سوال: مشخص کردن خواندنی یا نوشتنی بودن و باینری یا متنی بودن فایلی در fopen



mohamadtr
دوشنبه 26 خرداد 1393, 09:07 صبح
سلام
نحوه مشخص کردن خواندنی یا نوشتنی بودن وباینری یا متنی بودن فایلی که در fopenتعیین می گرددتوضیح دهید.

rahnema1
دوشنبه 26 خرداد 1393, 10:12 صبح
مطمئنی با سی شارپ می خواهی. فکر کنم با زبان سی می خوای
2.12.3.7 fopen
Declaration:

FILE *fopen(const char *filename, const char *mode);
Opens the filename pointed to by filename. The mode argument may be one of the following constant strings:
r read text mode
w write text mode (truncates file to zero length or creates new file)
a append text mode for writing (opens or creates file and sets file pointer to the end-of-file)
rb read binary mode
wb write binary mode (truncates file to zero length or creates new file)
ab append binary mode for writing (opens or creates file and sets file pointer to the end-of-file)
r+ read and write text mode
w+ read and write text mode (truncates file to zero length or creates new file)
a+ read and write text mode (opens or creates file and sets file pointer to the end-of-file)
r+b or rb+ read and write binary mode
w+b or wb+ read and write binary mode (truncates file to zero length or creates new file)
a+b or ab+ read and write binary mode (opens or creates file and sets file pointer to the end-of-file)


If the file does not exist and it is opened with read mode (r), then the open fails.

If the file is opened with append mode (a), then all write operations occur at the end of the file regardless of the current file position.

If the file is opened in the update mode (+), then output cannot be directly followed by input and input cannot be directly followed by output without an intervening fseek, fsetpos, rewind, or fflush.

On success a pointer to the file stream is returned. On failure a null pointer is returned.