标题:malloc的问题
取消只看楼主
xjy080
Rank: 2
等 级:论坛游民
帖 子:55
专家分:78
注 册:2008-9-15
结帖率:60%
已结贴  问题点数:20 回复次数:0 
malloc的问题
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
 
void fun (char str[100])
{
  printf("%d\n"),sizeof(str);
 }
int main ()
{
  char str[]="hello";
  char *p1=str;
  int n=10;
  char *p2=(char *)malloc(100);
  printf ("%d\n",sizeof(str));
  printf("%d\n",strlen(str));
  printf("%d\n",strlen(p1));
  printf("%d\n",sizeof(n));
  printf("%d\n",sizeof(p2));
  fun(p2);
  printf("\n");
  return 0;
}
源程序如上 最后一个printf输出的值哪位高人给解释一下 我应该是4啊 但是程序运行出来的结果 1245045
搜索更多相关主题的帖子: malloc 
2009-07-18 11:36



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-279751-1-1.html




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

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