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

2个小问题,请见内容,马上揭贴

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

    

(1)void   function(double   (*   pf)(double   *   x),int   n,   double   *point,  
    double   *   grad);  
  这个函数的声明中的double   (*   pf)(double   *   x)怎么解释?  
   
  (2)msdn上malloc的例子为什么会出错,运行提示:  
   
  error   c2440:   =   :   cannot   convert   from   void   *   to   char   *  
                  conversion   from   void*   to   pointer   to   non-void   requires   an   explicit   cast  
   
   
  #include   <stdlib.h>                   /*   for   _max_path   definition   */  
  #include   <stdio.h>  
  #include   <malloc.h>  
   
  void   main(   void   )  
  {  
        char   *string;  
   
        /*   allocate   space   for   a   path   name   */  
        string   =   malloc(   _max_path   );  
        if(   string   ==   null   )  
              printf(   "insufficient   memory   available\n"   );  
        else  
        {  
              printf(   "memory   space   allocated   for   path   name\n"   );  
              free(   string   );  
              printf(   "memory   freed\n"   );  
        }  
  }  
   
 

推荐阅读

  • AT&T可能因3G服务累计欠DoCoMo 36亿美元 [详细内容]
  • 无意中发现了V3x的两个功能 [详细内容]
  • 联想今年向微软采购100亿元 重视知识产权保护 [详细内容]
  • 微软评估XBOX360在中国内地市场上市可行性 [详细内容]
  • 李东生:TCL的冬天已经过去 亏损大为减少 [详细内容]
  • 中网络广告进帐超杂志 成为第4大广告媒体 [详细内容]
  • 惠普戴尔龙虎斗 三星打印机能否成为黑马 [详细内容]
  • 网友回答:
    网友:arfi

    (1):表示函数function第一个参数为一个"返回值为double,参数为double   *"的函数指针。

    网友:point_to

    1   函数指针!  
      2       string   =   malloc(   _max_path   );  
     

    网友:arfi

    (2):c++的编译器对类型检验非常严格,这可能是   msdn疏忽了,加上强制转换就   ok了。  
      string   =   (char   *)malloc(   _max_path   );

    网友:callzjy

    1、double   (*   pf)(double   *   x)   函数指针,返回值为double,参数为double   *  
      2、string   =   (char   *)malloc(   _max_path   );  
       
     

    网友:yzb1000

    double   (*   pf)(double   *   x)函数指针  
      参数是double   *类型  
      返回值也是

    网友:yzb1000

    malloc()的返回值是void   *

    网友:y_jx

    up

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