vC++6.0写文件时,如何让软件记住当前位置,并且以后能回到这个位置。 vC++6.0写文件时,如何让软件记住当前位置,并且以后能回到这个位置。我知道的内容是 CFile file; DWORD pos; pos=file.GetPosition(); 接下来怎么做呢?是file.seek(pos);吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 参数错了。其实我倒觉得用fgetpos/fseekpos比较舒服:Example// crt_fgetpos.c/* This program opens a file and reads * bytes at several different locations. */#include <stdio.h>int main( void ){ FILE *stream; fpos_t pos; char buffer[20]; if( (stream = fopen( "crt_fgetpos.txt", "rb" )) == NULL ) printf( "Trouble opening file\n" ); else { /* Read some data and then check the position. */ fread( buffer, sizeof( char ), 5, stream ); if( fgetpos( stream, &pos ) != 0 ) perror( "fgetpos error" ); else { fread( buffer, sizeof( char ), 10, stream ); printf( "10 bytes at byte %I64d: %.10s\n", pos, buffer ); } /* Set a new position and read more data */ pos = 14; if( fsetpos( stream, &pos ) != 0 ) perror( "fsetpos error" ); fread( buffer, sizeof( char ), 10, stream ); printf( "10 bytes at byte %I64d: %.10s\n", pos, buffer ); fclose( stream ); }}Input: crt_fgetpos.txtThis is the input for crt_fgetpos.Output10 bytes at byte 5: is the inp10 bytes at byte 14: put for cr DWORD dwPosition = cfile.GetPosition();lActual = cfile.Seek( dwPosition , CFile::begin ); 关于property sheet 外观问题........ (100分)求获取函数返回地址的问题 ClipBoard问题 ADO访问数据库的数据类型转换问题 编译问题 vc++怎样调用pro/e图呢??????(在线等或者给我发邮件) 江湖救急-小问题请delphi,vc兼具的大侠解答 怎样得到Dialog的背景颜色 请问怎样才能实现客户区拖动? 小发现:模态对话框向主窗口发送消息,导致程序崩溃???-仅限release版 请问在vc++中怎么样自己制作一个头文件 在线等待 help!数据库问题
// crt_fgetpos.c
/* This program opens a file and reads
* bytes at several different locations.
*/#include <stdio.h>int main( void )
{
FILE *stream;
fpos_t pos;
char buffer[20]; if( (stream = fopen( "crt_fgetpos.txt", "rb" )) == NULL )
printf( "Trouble opening file\n" );
else
{
/* Read some data and then check the position. */
fread( buffer, sizeof( char ), 5, stream );
if( fgetpos( stream, &pos ) != 0 )
perror( "fgetpos error" );
else
{
fread( buffer, sizeof( char ), 10, stream );
printf( "10 bytes at byte %I64d: %.10s\n", pos, buffer );
} /* Set a new position and read more data */
pos = 14;
if( fsetpos( stream, &pos ) != 0 )
perror( "fsetpos error" ); fread( buffer, sizeof( char ), 10, stream );
printf( "10 bytes at byte %I64d: %.10s\n", pos, buffer );
fclose( stream );
}
}
Input: crt_fgetpos.txt
This is the input for crt_fgetpos.
Output
10 bytes at byte 5: is the inp
10 bytes at byte 14: put for cr
lActual = cfile.Seek( dwPosition , CFile::begin );