首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

*talloc 照书中定义,编译出错解决方案

2012-02-11 
*talloc 照书中定义,编译出错#includestdio.hstructnode{intelementstructnode*next}structnode*tallo

*talloc 照书中定义,编译出错
#include   <stdio.h>
struct   node   {
              int   element;
              struct   node   *next;
              }

struct   node   *talloc()
{
              return   (struct   node   *)   malloc(sizeof(struct   node));
}          

为何DEV   CPP   编译时提示:
two   or   more   data   types   declaration   of   'talloc '

后面的程序如下

main()
{
            struct   node   *head;
            struct   node   *rear;
            struct   node   *p;
            head   =   talloc();
            (*head).element   =   1;
            head-> next   =   NULL;
           
            rear   =   talloc();
            (*rear).element   =   2;
            rear-> next   =   NULL;
           
            head-> next   =   rear;
            p=head;
            while   (p-> next   !=   NULL){
                        printf( "%d\n ",(*p).element);
                        p=   p-> next;
                        }
                       
            return   0;
}

[解决办法]
struct node {
int element;
struct node *next;
};/*要加分号*/

malloc的内存空间,最后用完要free释放

热点排行