2)传递一个数组的引用参数指针如定义: void run2(int* myArray)调用 :run1(){int iArray[1024]
#include<stdio.h>void f(int b[],int n)//子函数
{
int a[10]={1,2,3,4,5,6,7,8,9,10}//子函数中的数组
for(int i=0i<ni++) //复制数组
{
b[i]=a[i]
}
}main(){ int b[10]
int * bb f(b,10)//调用子函数 传递数组b作为存贮位置,和个数
for(int i=0i<10i++) //测试结果
{
printf("%d\n",b[i])
}
getwchar()
}
Private Sub Command1_Click()Dim n(), m As Integer
n = Array(1, 2, 3)
fn n, m
Print m
n = Array(1, 2, 3, 4, 5)
m = 0
fn n, m
Print m
End Sub
Private Sub fn(a(), x As Integer)
Dim i As Integer
For i = 0 To UBound(a)
x = x + a(i)
Next
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)