| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 823 人关注过本帖
标题:谁给我改一下,这是什么错误?
只看楼主 加入收藏
zyx1989
Rank: 1
等 级:新手上路
帖 子:86
专家分:2
注 册:2011-9-17
结帖率:83.33%
收藏
 问题点数:0 回复次数:2 
谁给我改一下,这是什么错误?
:\Documents and Settings\Administrator\桌面\Cpp1.cpp(14) : error C2018: unknown character '0xa3'
C:\Documents and Settings\Administrator\桌面\Cpp1.cpp(14) : error C2018: unknown character '0xac'
C:\Documents and Settings\Administrator\桌面\Cpp1.cpp(14) : error C2143: syntax error : missing ';' before '*'
C:\Documents and Settings\Administrator\桌面\Cpp1.cpp(14) : error C2065: 'q' : undeclared identifier
C:\Documents and Settings\Administrator\桌面\Cpp1.cpp(14) : error C2100: illegal indirection
C:\Documents and Settings\Administrator\桌面\Cpp1.cpp(22) : error C2440: '=' : cannot convert from 'struct student *' to 'int'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
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)
#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("删除成功!");
          free(p);
      }
      return(h);
  }
 void print(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);
    print(h);
}


搜索更多相关主题的帖子: character Documents before 
2011-09-26 12:35
czsbc
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
帖 子:469
专家分:1700
注 册:2008-12-13
收藏
得分:0 
这贴子见过很多次了。
LZ居然还在发,没有看别人的回答吗。
在说这种编译问题都很容易解决的。
h=(stud *)malloc(sizeof(stud));
     if(h==NULL)
     {
         printf("not enough memory!");
         return(0);
     }
     h=NULL;//这里h=NULL想当于内存没有分配,还导致内存泄漏。你要是想用头结点就h->link=NULL;
另外delete是C++关键字,说过了,都没有去改。
不要自己发的贴子都不管了。那样别人不会再看你的贴子了。

2011-09-26 12:47
zyx1989
Rank: 1
等 级:新手上路
帖 子:86
专家分:2
注 册:2011-9-17
收藏
得分:0 
他们说的改了也有错啊,你说对了,是delete 的问题
2011-09-26 13:06
快速回复:谁给我改一下,这是什么错误?
数据加载中...
 
   



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

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