小编AGP*_*eus的帖子

得到几个错误,包括"非法使用此类型作为表达式"

尝试运行该*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

0
推荐指数
1
解决办法
118
查看次数

标签 统计

c ×1