標題:
通過指針引用數(shù)組元素
[打印本頁]
作者:
liuda
時間:
2015-1-22 02:09
標題:
通過指針引用數(shù)組元素
//通過指針引用數(shù)組元素
#include<stdio.h>
void main()
{int i;
int a[3]={1,3,5};//三個數(shù)就能說明情況了,要那么多數(shù)干嘛
for(i=0;i<3;i++)//這樣多簡潔,真不知道書上搞那么多干嘛
{//不知道你要教什么嘛
printf("%d\n",*(a+i));
}
}
//通過指針引用數(shù)組元素
#include<stdio.h>
void main()
{int i,*p;
int a[3]={1,3,5};
p=a;
for(i=0;i<3;i++)
{
printf("%d\n",*(p+i));
}
}
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1