声明指定了错误两个或多个数据类型 [英] two or more data types in declaration specifiers error

查看:272
本文介绍了声明指定了错误两个或多个数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是pretty新的C

I am pretty new to C.

我得到这个错误:

内置功能不兼容的隐式声明'的malloc

incompatible implicit declaration of built-in function ‘malloc’

甚至当我确定的基础上的答案code,包括STDLIB,我仍然得到:

Even when I fix the code based on the answers to include stdlib, I still get:

声明指定了两个或更多的数据类型。

two or more data types in declaration specifiers

当试图做到这一点:

struct tnode
{
    int data;

    struct tnode * left;
    struct tnode * right;
}

struct tnode * talloc(int data){
    struct tnode * newTnode;
    newTnode = (struct tnode *) malloc (sizeof(struct tnode));
    newTnode -> data = data;
    newTnode -> left = NULL;
    newTnode -> right = NULL;
    return newTnode;
}

如何解决呢?

推荐答案

您必须把; 后面的结构声明:

struct tnode
{
    int data;

    struct tnode * left;
    struct tnode * right;
}; // <-- here

这篇关于声明指定了错误两个或多个数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆