首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

新手请问读写文件有关问题

2012-03-21 
新手请教读写文件问题因为对读写文件进行了封装:/*filesystemIO*/intzopen(constchar*filename,intoflag,i

新手请教读写文件问题
因为对读写文件进行了封装:
/*   file   system   IO   */
int   zopen(   const   char   *   filename,   int   oflag,   int   pmode   );
int   zcreate(   const   char   *   filename,   int   pmode   );
int   zread(   int   handle,   void   *buffer,   unsigned   int   count   );
int   zwrite(   int   handle,   const   void   *buffer,   unsigned   int   count   );
int   zclose(   int   handle   );
int   zflush(   int   handle   );
int   zeof(   int   handle   );
int   zsize(   int   handle   );
long   zlseek(   int   handle,   long   offset,   int   origin   );
long   ztell(   int   handle   );
int   zchsize(   int   handle,   int   size   );
int   ztruncate(   int   handle   );
int   zlookup(   const   char   *   filename   );
int   zgeterr(   void   );
int   zdelete(   const   char   *   filename   );
int   zrename(   const   char   *oldname,   const   char   *newname);

/*   find   file   */
FINDFILE   *   OpenFindFile(const   char   *   dir);
int   FindFirst(FILEINFO   *   info,   FINDFILE   *   find_handle);
int   FindNext(FILEINFO   *info,   FINDFILE   *   find_handle);
int   CloseFindFile(FINDFILE   *   find_handle);

/*   file   system   operation   */
int   FormatFileSystem(void);
void   FlushFileSystem(void);
int   GetFileInfo(const   char   *   filename,   FILEINFO   *   pinfo);

/*   file   system   space   information   */
int   GetFilesystemFree(void);
int   GetFilesystemUsed(void);
int   GetFilesystemTotal(void);

现在想从文件temp.txt中读出内容,(temp.txt中存的是一组数字200701031)
能够更新temp.txt里面的内容

[解决办法]
int zopen( const char * filename, int oflag, int pmode ); 打开文件,使用合适的mode
然后
int zread( int handle, void *buffer, unsigned int count ); 读取内容
int zwrite( int handle, const void *buffer, unsigned int count ); 更新内容
[解决办法]
补充,读写操作完成后要记得关闭文件。
int zclose( int handle );

热点排行