| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 612 人关注过本帖
标题:这是什么错误呢?
只看楼主 加入收藏
zyx1989
Rank: 1
等 级:新手上路
帖 子:86
专家分:2
注 册:2011-9-17
结帖率:83.33%
收藏
已结贴  问题点数:20 回复次数:7 
这是什么错误呢?
#include<stdio.h>
#include<malloc.h>
#include<stdlib.h>
#include<string.h>
typedef struct student
{
    int num;
   
    struct student *link;
}stud;

 stud* creat(int n)
{
    stud *h,*p;
    int i;
    h=(stud *)malloc(sizeof(stud));
    if(h==NULL)
    {
        printf("not enough memory!");
        return(0);
    }
    h=NULL;
    for(i=0;i<=n;i++)
    {
        
        
        if((p=(struct student *)malloc(sizeof(stud)))==NULL)
            
            
            
        {
            printf("内存不足!");
            return(0);
        }
        scanf("%d",&p->num);
        
        p->link=h;
        h=p;
        
    }
    return(h);
}
   
  void search(stud *h)
  {
    stud *p;
    int m;
    printf("请输入需查找数据!");
    scanf("%d",&m);
    p=h;
    while(p!=NULL)
    {
   
        if(m==p->num)
        {printf("%d\n",m);
        
         break;
        }
        else
         p=p->link;
    }
         
   
   
   
  }
  stud *delete(stud *h)
  {
      stud *q,*p;
      p=h;
      int n;
      q=h->link;
      printf("请输入要删除的数字!");
      scanf("%d",&n);
      
      while(p!=NULL&&q!=NULL)
      {
          p=p->link;
          q=q->link;
          if(n=q->num)
          p->link=q->link;
          else if
          (n=p->num)
           q=h;
          printf("删除成功!");
      }
      return(h);
  }
 void printf(stud *h)
 {
     stud *p;
     p=h;
     while(p!=NULL)
     {
         printf("%d",p->num);
         p=p->link;
     }
 }
void main()
{
    struct student *h;
   
    h=(struct student *)creat(3);
   
    search(h);
    delete(h);
    printf(h);
}

搜索更多相关主题的帖子: include memory return 
2011-09-25 13:31
zyx1989
Rank: 1
等 级:新手上路
帖 子:86
专家分:2
注 册:2011-9-17
收藏
得分:0 
怎么没人回啊
2011-09-25 15:45
pauljames
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:千里冰封
威 望:9
帖 子:1555
专家分:10000
注 册:2011-5-8
收藏
得分:5 
你的错误提示呢?

经常不在线不能及时回复短消息,如有c/单片机/运动控制/数据采集等方面的项目难题可加qq1921826084。
2011-09-25 16:13
A13433758072
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:广东潮州
等 级:小飞侠
威 望:1
帖 子:1182
专家分:2784
注 册:2010-7-22
收藏
得分:5 
回复 楼主 zyx1989
printf(h);你夸张点吧! 发下题目吧

一步一个脚印...............................默默地前进.....
诚邀乐于解答c菜鸟问题,的热心网友加入,  QQ群38490319
2011-09-25 18:28
laoyang103
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:内蒙古包头
等 级:贵宾
威 望:19
帖 子:3082
专家分:11056
注 册:2010-5-22
收藏
得分:5 
你遇到了什么情况 不要只贴代码呀

                                         
===========深入<----------------->浅出============
2011-09-25 18:38
zyx1989
Rank: 1
等 级:新手上路
帖 子:86
专家分:2
注 册:2011-9-17
收藏
得分:0 
提示没有头文件。ompiling...
Cpp1.cpp
c:\documents and settings\administrator\桌面\cpp1.cpp(67) : error C2059: syntax error : 'delete'
c:\documents and settings\administrator\桌面\cpp1.cpp(68) : error C2143: syntax error : missing ';' before '{'
c:\documents and settings\administrator\桌面\cpp1.cpp(68) : error C2447: missing function header (old-style formal list?)
执行 cl.exe 时出错.

Cpp1.exe - 1 error(s), 0 warning(s)
2011-09-25 20:02
czsbc
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
帖 子:469
专家分:1700
注 册:2008-12-13
收藏
得分:5 
delete是C++关键字。
2011-09-25 22:00
zyx1989
Rank: 1
等 级:新手上路
帖 子:86
专家分:2
注 册:2011-9-17
收藏
得分:0 
不好意思,没看到
2011-09-26 13:07
快速回复:这是什么错误呢?
数据加载中...
 
   



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

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