首页   |   IT资讯   |   综合资讯   |   开发   |   软件   |   问答   |   网络技术   |   网络综合
更多:
当前位置:首页 » 手机数码
文章正文

请帮调试一下

类型:转载   责任编辑:asp   日期:2007/03/01

    

题目:  
  有若干个学生的成绩(每个学生有4门课程),要求在用户输入学生序号以后,能输出该学生的全部成绩,用指针函数来实现。  
  程序:  
  #include   "stdafx.h"  
  #include   "stdio.h"  
  main()  
  {  
          float   score[][4]={{60,70,80,90},{56,89,67,88},{34,78,90,66}};  
  float   *seach(float   (*pointer)[4],int   n);  
  float   *p;  
  int   i,m;  
  printf("enter   the   number   of   student:");  
  scanf("%d",&m);  
  printf("the   scores   of   no.%d   are:\n",m);  
  p=search(score,m);  
  for(i=0;i<4;i++)  
  printf("%5.2f\t",*(p+i));  
  }  
  float   *search(float   (*pointer)[4],int   n)  
  {  
  float   *pt;  
  pt=*(pointer+n);  
  return(pt);  
  }  
   
  compiling...  
  b.cpp  
  d:\program   files\microsoft   visual   studio\myprojects\b\b.cpp(15)   :   error   c2065:   search   :   undeclared   identifier  
  d:\program   files\microsoft   visual   studio\myprojects\b\b.cpp(15)   :   error   c2440:   =   :   cannot   convert   from   int   to   float   *  
                  conversion   from   integral   type   to   pointer   type   requires   reinterpret_cast,   c-style   cast   or   function-style   cast  
  d:\program   files\microsoft   visual   studio\myprojects\b\b.cpp(18)   :   warning   c4508:   main   :   function   should   return   a   value;   void   return   type   assumed  
  d:\program   files\microsoft   visual   studio\myprojects\b\b.cpp(20)   :   error   c2373:   search   :   redefinition;   different   type   modifiers  
  error   executing   cl.exe.  
   
  b.obj   -   3   error(s),   1   warning(s)  
 

推荐阅读

  • 七年磨一剑 高交会成交项目终结果 [详细内容]
  • 鲍岳桥说网络游戏 [详细内容]
  • 发掘SCP550中个人资料的秘密 [详细内容]
  • 火狐市场增涨已经碰壁 浏览器格局将趋稳定 [详细内容]
  • Symbian新版系统支持高分辨率相机和3D游戏 [详细内容]
  • 电话簿的正确查询方法 [详细内容]
  • 浸泡30分钟没问题 世界首款液晶防水品 [详细内容]
  • 网友回答:
    网友:flab_lwq

    如果把     pt=*(pointer+n)        
      改为         pt=(*pointer+n);  
      pointer是一个pointer   to   pointer,搞清楚*pointer++和*(pointer++)的区别  
       
      pointer-->{60,70,80,90}  
                          {56,89,67,88}  
                          {34,78,90,66}  
      *pointer++==>pointer-->70  
      *(pointer++)==>pointer-->56  
     

    .
      最佳浏览:1024X768 MSIE
    ©2007 jqmk.com.cn All Rights Reserved