| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 545 人关注过本帖
标题:大家帮忙看看什么问题
只看楼主 加入收藏
wjcloudy
Rank: 1
来 自:辽宁大连
等 级:新手上路
帖 子:44
专家分:0
注 册:2007-11-6
收藏
 问题点数:0 回复次数:2 
大家帮忙看看什么问题
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define NULL 0
struct node
{
    char number[15];
    char name[10];
    char sex;
    struct node *link;
}
struct node * creattab(int n)
{
    int i;
    struct node *phead,*ptail,*pnew;
    pnew=(struct node *)malloc(sizeof(struct node));
    if(pnew==NULL)
    {
        printf("内存不足!\n");
        exit(1);
    }
    else
    {
        printf("Input number:");
        gets(pnew->number);
        printf("Input name:");
        gets(pnew->name);
        printf("Input sex:");
        gets(pnew->sex);
        pnew->link=NULL;
        phead=pnew;
        ptail=pnew;
    }
    for(i=1;i<n;i++)
    {
        pnew=(struct node *)malloc(sizeof(struct node));
        if(pnew==NULL)
        {
            printf("内存不足!\n");
            exit(1);
        }
        else
        {
            printf("Input number:");
            gets(pnew->number);
            printf("Input name:");
            gets(pnew->name);
            printf("Input sex:");
            gets(pnew->sex);
            pnew->link=NULL;
            phead->link=pnew;
            ptail->link=pnew;
            ptail=pnew;
        }
    }
    return(phead);
}
int main()
{
    struct node *creattab(int n);
    int m=3;
    struct node *phead,*pnew,*p;
    p=creattab(m);
    phead=p;
    return 0;
}
这是一个做链表的程序,我调了很多次都说struct node unexpected.我实在找不到有什么错误,
请个位多多指教,谢谢了!
2007-12-21 22:17
灭火的风
Rank: 2
来 自:杭州
等 级:论坛游民
帖 子:161
专家分:10
注 册:2006-6-15
收藏
得分:0 
定义结构之后要写一个分号
2007-12-21 22:22
wjcloudy
Rank: 1
来 自:辽宁大连
等 级:新手上路
帖 子:44
专家分:0
注 册:2007-11-6
收藏
得分:0 
哦!!!
恍然醒悟,怎么就没看到呢
谢谢哈
2007-12-21 22:24
快速回复:大家帮忙看看什么问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019322 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved