动态分配问题。。。寻找大神。。。
大神,下面的函数里Error()和FatalError()是什么东西?是函数吗?如果是函数,那么它的作用是什么?在哪个头文件里?
谢谢!!!!!
#include<stdio.h>
#include<malloc.h>
#define MinTableSize 3.14
enum KindOfEntry{ Legitimate, Empty,Delete };
struct HashEntry
{
int Element;
enum KindOfEntry Info;
};
typedef struct HashEntry Cell;
struct HashTbl
{
int TableSize;
Cell *TheCells;
};
typedef struct HashTbl HashTable;
HashTable *InlitializeTable( int TableSize )
{
if( TableSize < MinTableSize )
{
Error( "TableSize is too small" );
return NULL;
}
HashTable *H = ( HashTable * )malloc( struct HashTbl );
if( H == NULL )
{
FatalError( "Out Of Space!!!" );
}
H->TableSize = 17;
H->TheCells = ( Cell * )malloc( sizeof( Cell ) * H->TableSize );
if( H->TheCells == NULL )
{
FatalError( "Out Of Space!!!" );
return NULL;
}
int i;
for( i = 0; i < H->TableSize ; ++i )
{
H->TheCells[i].Info = Empty;
}
return H;
}
[解决办法]
可能是函数,也可能是#define,楼主贴的代码不全吧。
[解决办法]
按照这样大写的,一般都是宏
也可能是函数,但大多数情况下是宏
[解决办法]
不清楚什么原因,看看大家是怎么说的
[解决办法]
函数?宏定义?