设为首页 加入收藏

TOP

※C++随笔※=>☆C++基础☆=>※№ C++文件操作 (fstream)(四)
2015-11-21 01:15:20 来源: 作者: 【 】 浏览:17
Tags:随笔 > 基础 文件 操作 fstream
D MODEL_NOREPLACE ? = std::ios::_Noreplace; // 0x40, file exists generates an error when used in combination, often and out?
? ? ? ? ? ? ? ? ? ? ? ? static const WORD MODEL_BINARY ? ? ?= std::ios::binary; ? ? // 0x80, binary format file?
? ? * @param ? ? ? ? WORD wAccess?
? ? ? ? ? ? ? ? ? ? ? ? static const WORD ACCESS_ORDINARY ? = 0; ? ? ? ? ? ? ? ? ? ?// 0: ordinary files, open access?
? ? ? ? ? ? ? ? ? ? ? ? static const WORD ACCESS_READONLY ? = 1; ? ? ? ? ? ? ? ? ? ?// 1: read-only file?
? ? ? ? ? ? ? ? ? ? ? ? static const WORD ACCESS_HIDDEN ? ? = 2; ? ? ? ? ? ? ? ? ? ?// 2: hidden file?
? ? ? ? ? ? ? ? ? ? ? ? static const WORD ACCESS_SYSTEM ? ? = 4; ? ? ? ? ? ? ? ? ? ?// 4: System Files?
? ? * @return VOID?
? ? * @note ? ? ? ? Note the slash in the path name to dual-write, such as: "\\MyFiles\\ReadMe.txt"?
? ? * @attention ? ?The default way to open a file to open the binary file reading and writing?
? ? ? ? ? ? ? ? ? ? The default file ordinary files, open access?
? ? */ ?
? ? VOID Open(const NCHAR* cpFilePath, WORD wOpenModel = MODEL_IN|MODEL_OUT|MODEL_BINARY, WORD wOpenAccess = ACCESS_ORDINARY); ?
??
////////////////////////////////Check if successfully opened////////////////////////////////////////// ?
? ? /**?
? ? * Good (Check if successfully opened)?
? ? *?
? ? * @param VOID?
? ? * @return BOOL?
? ? * @note?
? ? * @attention?
? ? */ ?
? ? BOOL Good(VOID); ?
??
? ? /**?
? ? * Fail (Check if successfully opened)?
? ? *?
? ? * @param VOID?
? ? * @return BOOL?
? ? * @note?
? ? * @attention?
? ? */ ?
? ? BOOL Fail(VOID); ?
??
? ? /**?
? ? * IsOpen (Check if successfully opened)?
? ? *?
? ? * @param VOID?
? ? * @return BOOL?
? ? * @note ? ? ? ? Generally use this method to determine if a file is open successfully?
? ? * @attention?
? ? */ ?
? ? BOOL IsOpen(VOID); ?
??
/////////////////////////////////Reading and writing binary files///////////////////////////////////////// ?
? ? /**?
? ? * Put (Reading and writing binary files)?
? ? *?
? ? * @param ? ? ? ? NCHAR ch?
? ? * @return VOID?
? ? * @note ? ? ? ? put () function to write to the stream a character prototype ofstream & put (char ch), ?
? ? ? ? ? ? ? ? ? ? the use of relatively simple, such as file1.put ('c'); is to write to the stream a character 'c'.?
? ? * @attention?
? ? */ ?
? ? VOID Put(NCHAR ch); ?
? ? ??
? ? /**?
? ? * Get (Reading and writing binary files)?
? ? *?
? ? * @param ? ? ? ? NCHAR& ch?
? ? * @return VOID?
? ? * @note ? ? ? ? put () corresponds to the form: ifstream & get (char & ch); function is to read a single character ?
? ? ? ? ? ? ? ? ? ? from the stream, and the result is stored in the reference ch, if the end of the file, and returns ?
? ? ? ? ? ? ? ? ? ? a null character. As file2.get (x); represents a character read from the file, and read characters ?
? ? ? ? ? ? ? ? ? ? stored in x.?
? ? * @attention?
? ? */ ?
? ? VOID Get(NCHAR& ch); ?
??
? ? /**?
? ? * Get (Reading and writing binary files)?
? ? *?
? ? * @param ? ? ? ? NCHAR* pStr?
? ? * @param ? ? ? ? DWORD dwGetNum?
? ? * @param ? ? ? ? NCHAR chEndChar?
? ? * @return VOID?
? ? * @note ? ? ? ? ifstream & get (char * buf, int num, char delim = '\ n'); this form to read characters into the ?
? ? ? ? ? ? ? ? ? ? array pointed to by buf until reads num characters or encounter characters specified by delim, ?
? ? ? ? ? ? ? ? ? ? ifdelim this parameter will use the default value of the newline character '\ n'. For example:?
? ? ? ? ? ? ? ? ? ? file2.get (str1, 127, 'A') ;/ / read characters from a file into a string str1 terminate when ?
? ? ? ? ? ? ? ? ? ? to encounter characters 'A' or rea
首页 上一页 1 2 3 4 5 6 7 下一页 尾页 4/11/11
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇POJ3006:Dirichlet's Theorem.. 下一篇字符串系列――10010 Where's..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: