CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VC/MFC >  基础类

在VC6中,对链表的操作!看看有什么错误,VC编译是提示有9个错误,谢谢,急需!

楼主csdnhw(巍巍)2004-07-03 11:56:04 在 VC/MFC / 基础类 提问

在VC6中,对链表的操作!看看有什么错误,VC编译是提示有9个错误,谢谢,急需!  
   
  //   1.cpp   :   Defines   the   entry   point   for   the   console   application.  
  //  
   
  #include   "stdafx.h"  
  #include   <stdlib.h>  
  #define   Max   10  
  //#include   "stdio.h"  
  #define   null   0  
   
  struct   list  
  {  
  int   number;  
  char   name[Max];  
  struct   list   *   next  
  };  
   
   
  typedef   struct   list   node;  
  typedef   node   *   link;  
   
  /*--------------------------------------------*/  
  /*   释放链表                                                                       */  
  /*--------------------------------------------*/  
  void   free_list(link   head)  
  {  
  link   pointer;  
  while(head!=null)  
  {  
  pointer=head;  
  head=head->next;  
  free(pointer);  
  }  
  }  
   
  /*--------------------------------------------*/  
  /*   输出链表数据                                                               */  
  /*--------------------------------------------*/  
  void   print_list(link   head)  
  {  
  link   pointer;  
  pointer=head;  
  while(pointer!=null)  
  {  
  printf("##input   data##\n");  
  printf("data   number:%d\n",pointer->number     );  
  printf("data   name:%d\n",pointer->name   );  
  pointer=pointer->next   ;  
   
  }  
  }  
   
  /*--------------------------------------------*/  
  /*   建立链表                                                                       */  
  /*--------------------------------------------*/  
  link   create_list(link   head)  
  {  
  int   datanum;  
  char   dataname[max];  
  link   temp;  
  link   pointer;  
  int   i;  
   
  head=(link)malloc(sizeof(node));  
   
  if   (head==null)  
  {  
  printf("memory   allcate   failure!!\n");  
  }  
  else  
  {  
  datanum=1;  
  printf("please   input   the   data   name:");  
  scanf("%s",dataname);  
  head->number   =datanum;  
   
  for(i=0;i<=max;i++)  
  head->name[i]=dataname[i];  
   
  head->next   =null;  
   
  pointer=head;  
   
  while(1)  
  {  
  datanum++;  
  temp=(link)malloc(sizeof(node));  
  printf("please   input   the   data   name:");  
  scanf(%s,dataname);  
  if(dataname[0]=='0')  
  break;  
  temp->number   =datanum;  
  for(i=0;i<=max;i++)  
  {  
  temp->name[i]=dataname[i];  
  }  
   
  temp->next   =null;  
  pointer->next=temp;    
  }  
  return   head;  
  }  
  }  
   
   
  void   main()  
  {  
  link   head;  
  head=create_list(head);  
  if(head!=head)  
  {  
  print_list(head);  
  free_list(head);  
  }  
   
  }  
   
  问题点数:20、回复次数:14Top

1 楼jink(毁人不倦)回复于 2004-07-03 11:57:54 得分 0

错误提示在哪Top

2 楼csdnhw(巍巍)回复于 2004-07-03 11:58:50 得分 0

没有提示,只说有9个错误!Top

3 楼csdnhw(巍巍)回复于 2004-07-03 11:59:58 得分 0

本问题的提出者,QQ:79341545     在线等待  
   
  加入时,请说明身份Top

4 楼jink(毁人不倦)回复于 2004-07-03 12:01:20 得分 20

-_-!!!,把Build框里的东东都帖上来Top

5 楼csdnhw(巍巍)回复于 2004-07-03 12:06:50 得分 0

--------------------Configuration:   1   -   Win32   Debug--------------------  
  Compiling...  
  1.cpp  
  D:\Program   Files\Microsoft   Visual   Studio\MyProjects\1\1.cpp(16)   :   error   C2143:   syntax   error   :   missing   ';'   before   '}'  
  D:\Program   Files\Microsoft   Visual   Studio\MyProjects\1\1.cpp(59)   :   error   C2065:   'max'   :   undeclared   identifier  
  D:\Program   Files\Microsoft   Visual   Studio\MyProjects\1\1.cpp(59)   :   error   C2057:   expected   constant   expression  
  D:\Program   Files\Microsoft   Visual   Studio\MyProjects\1\1.cpp(59)   :   error   C2466:   cannot   allocate   an   array   of   constant   size   0  
  D:\Program   Files\Microsoft   Visual   Studio\MyProjects\1\1.cpp(59)   :   error   C2133:   'dataname'   :   unknown   size  
  D:\Program   Files\Microsoft   Visual   Studio\MyProjects\1\1.cpp(89)   :   error   C2143:   syntax   error   :   missing   ')'   before   '%'  
  D:\Program   Files\Microsoft   Visual   Studio\MyProjects\1\1.cpp(89)   :   error   C2660:   'scanf'   :   function   does   not   take   0   parameters  
  D:\Program   Files\Microsoft   Visual   Studio\MyProjects\1\1.cpp(89)   :   error   C2065:   's'   :   undeclared   identifier  
  D:\Program   Files\Microsoft   Visual   Studio\MyProjects\1\1.cpp(89)   :   error   C2059:   syntax   error   :   ')'  
  Error   executing   cl.exe.  
   
  1.exe   -   9   error(s),   0   warning(s)Top

6 楼jink(毁人不倦)回复于 2004-07-03 12:07:46 得分 0

struct   list  
  {  
  int   number;  
  char   name[Max];  
  struct   list   *   next  
  };  
   
  struct   list   *   next少个;号Top

7 楼jink(毁人不倦)回复于 2004-07-03 12:09:23 得分 0

搜索所有的max,把改成MaxTop

8 楼jink(毁人不倦)回复于 2004-07-03 12:10:36 得分 0

scanf(%s,dataname);  
   
  改成  
  scanf("%s",dataname);Top

9 楼xdsh00(蛋糕芝麻叮叮糖)回复于 2004-07-03 12:11:38 得分 0

对呀!  
  struct   list   *   next少个;号Top

10 楼csdnhw(巍巍)回复于 2004-07-03 12:15:12 得分 0

都改了,又提示  
   
  --------------------Configuration:   1   -   Win32   Debug--------------------  
  Compiling...  
  1.cpp  
  D:\Program   Files\Microsoft   Visual   Studio\MyProjects\1\1.cpp(103)   :   warning   C4715:   'create_list'   :   not   all   control   paths   return   a   value  
  D:\Program   Files\Microsoft   Visual   Studio\MyProjects\1\1.cpp(109)   :   warning   C4700:   local   variable   'head'   used   without   having   been   initialized  
  Linking...  
   
  1.exe   -   0   error(s),   2   warning(s)  
   
   
  Top

11 楼csdnhw(巍巍)回复于 2004-07-03 12:25:50 得分 0

这个怎么改呀,朋友!!Top

12 楼jink(毁人不倦)回复于 2004-07-03 12:41:16 得分 0

create_list有可能没有返回值,自己检查create_list函数  
   
  link   head;  
  head=create_list(head);  
  if(head!=head)  
   
  这个调用真搞笑  
   
   
  哥们,我觉得你很懒Top

13 楼csdnhw(巍巍)回复于 2004-07-03 13:04:48 得分 0

怎么呢Top

14 楼csdnhw(巍巍)回复于 2004-07-03 13:10:03 得分 0

哥们,分给你了,希望以后能成朋友,你还多帮我,谢谢了Top

相关问题

  • VC编译问题
  • vc++编译问题???
  • VC 编译问题!!
  • vc编译错误
  • vc不能编译
  • 编译问题!VC
  • vc编译 程序
  • VC++编译问题
  • VC编译问题
  • VC编译问题??????

关键词

  • win32
  • cpp
  • vc
  • visual
  • program
  • microsoft
  • dataname
  • head
  • myprojects
  • 错误

得分解答快速导航

  • 帖主:csdnhw
  • jink

相关链接

  • Visual C++类图书
  • Visual C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo