行者的学习博客

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

#i nclude <stdio.h>
int * test(int *b);
int *array;

int main()
{
 
int a = 1,c;
 
int *temp;
 
 temp 
= test(&a);
 
 
for(c = 0; c < a; c++)
 
{
  printf(
"temp[%d]=%d\n",c,temp[c]);
 }

 
 getch();
}


int * test(int *b)
{
 
int a;
 
 
for(a = 0; a < 10; a++)
 
{
  array[a] 
= a;
 }

 
 
*= a;
 
 
return array;
 
}

2。传参数
#i nclude 
<stdio.h>

void test(int *b, int *array);

int main()
{
 
int a = 1,c;
 
int temp[10];
 
 test(
&a, temp);
 
 
for(c = 0; c < a; c++)
 
{
  printf(
"temp[%d]=%d\n",c,temp[c]);
 }

 
 getch();
}


void test(int *b, int *array)
{
 
int a;
 
 
for(a = 0; a < 10; a++)
 
{
  array[a] 
= a;
 }

 
 
*= 10;
 
}

2传参数相当于传递的地址,直接在地址上对其对应的值上进行操作。类似全局

posted on 2009-06-30 09:30  ylclass  阅读(1519)  评论(1编辑  收藏  举报