退出函数时想保留这个指针
int s[100];main()
{
fun1
}
-----------------------不同文件
extern s;
fun1()
{
fun2(&s,...)
}
-------------------------
fun2(static *p,...)
{
.....
p++;
}
退出函数时想保留这个指针p,就是调用fun2时要逐个读取a的数据,这么做不行,一调用完fun2指针就不知道指哪去了,该怎么改
程序代码:fun2(static *p,...)
{
.....
p++;
static *pp=p; /*下一次进入函数时,在这一句以下的代码可以留住.*/
}
程序代码:int *pp; /*全局指针,pp*/
int s[100];
main()
{
fun1
}
-----------------------不同文件
extern s;
fun1()
{
fun2(&s,...)
}
-------------------------
fun2(static *p,...)
{
.....
p++;
pp=p; /*把p付给pp*/
}