标题:大家帮忙看看什么问题
只看楼主
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



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-193775-1-1.html




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

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