c返回数组

 

#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;
 
}

posted @ 2007-04-05 18:01  fool  阅读(1080)  评论(0编辑  收藏  举报