尝试运行该*HNum_clone
函数时,我遇到了几个错误.可能缺少一些真正愚蠢的东西?HNum应该代表任何长度.
typedef struct _HNum
{
char *a;
}HNum;
/*
* Allocates a new HNum and sets its value to 0.
* RETURN VALUE:
* Returns a pointer to the new number, or NULL if the allocation failed.
*/
HNum *HNum_alloc()
{
HNum *newNum;
newNum->a = (char*)malloc(2*sizeof(char));
if(!newNum->a) return NULL;
newNum->a = "0";
return newNum;
}
/*
*Allocates a new HNum with the same value as hnum. It is the caller's
* responsibility to free the returned HNum.
* …
Run Code Online (Sandbox Code Playgroud) c ×1