一个关于内存空间操作的问题,请高手解答......
liufx 2004-12-07 10:02:44 char * buffer;
int CFind_Sent_Word::set_sent_data( const char * sent_string )
{
.......
wcbuf_size = end - beg + 1;
buffer = new char[wcbuf_size+10];
FILE *file;
file = fopen( wc_path , "rb" );
if(file == NULL )
{
delete []buffer; return 0;
}
fseek( file , beg , SEEK_SET );
fread( buffer , sizeof(char) , wcbuf_size , file );
fclose( file);
buffer[wcbuf_size] = '\0';
.......
pt = find_prefix(data);
if(pt!=NULL)
{
//............
........
}
...........
delete []buffer;
return max_sent_buf_num;
}
char * CFind_Sent_Word::find_prefix( const char * data )
{
char * part_buf = NULL;
...........
//
unsigned long int lin = end - beg + 1;
FILE *file;
file = fopen(wc_path , "rb");
if(file == NULL) return NULL;
part_buf = new char[lin];
fseek( file , beg , SEEK_SET );
fread( part_buf , sizeof(char) , lin , file );
part_buf[lin] = '\0';
fclose(file);
............
///
delete []part_buf; // 程序运行在词出现错误
return NULL;
}
请问,为什么程序在delete []part_buf就出现错误呢,好像是内存块的错误