| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 780 人关注过本帖
标题:大家帮我看看错在那里了啊!
只看楼主 加入收藏
wangyinshiwo
Rank: 1
等 级:新手上路
帖 子:75
专家分:0
注 册:2007-11-9
收藏
 问题点数:0 回复次数:0 
大家帮我看看错在那里了啊!
/* Note:Your choice is C IDE */
#include "stdio.h"
#include<malloc.h>
typedef struct node
{
    char ch;
    struct node *next;
}linkstr;
linkstr *creat(char *ch)
{
    linkstr *p,*head,*q;
    int i=0;
    p=head=(linkstr *)malloc(sizeof(linkstr));
    head->next=NULL;
    while(ch[i]!=0)
    {
        q=(linkstr *)malloc(sizeof(linkstr));
        p->ch=ch[i];
        p->next=q;
        q->next=NULL;
        p=q;i++;
    }
    return head;
}
void output(linkstr *head)
{
    linkstr *p;
    p=head->next;
    while(p)
    {
        printf("%c",p->ch);
        p=p->next;
    }
}
void main()
{
    linkstr *head;
    int i;char str;
    head=(linkstr *)malloc(sizeof(linkstr));
    for(i=0;i<10;i++)
    {
        scanf("%c",&str);
        head=creat(&str);
    }
    output(head);
}

[[it] 本帖最后由 wangyinshiwo 于 2008-5-8 14:10 编辑 [/it]]

[[it] 本帖最后由 wangyinshiwo 于 2008-7-20 20:50 编辑 [/it]]
搜索更多相关主题的帖子: linkstr next head node malloc 
2008-05-03 09:52
快速回复:大家帮我看看错在那里了啊!
数据加载中...
 
   



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

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