c+i 数组名+数字i 表示 指针偏移i个类型的字节,int是4个字节,就偏移i个4字节,指向下i个数组内元素的地址。
*(c+i) 数组名+数字i 然后解除引用后,就是调用该地址的内容? 还是该怎么说 反正指向内存地址存储的值。
c[i] 直接传递的是值,不是地址。
#include <iostream>
using namespace std;
void test( const char* te)
{
cout << te << "\n\n"<< endl;
}
void test1(const int* t)
{
cout << t << "\n\n"<< endl;
}
void test2(const int* t)
{
for (int i = 0; i < 5; ++i)
{
cout << t+i << endl;
cout << *(t + i) <<endl;
cout << t[i] << endl;
}
cout << t << endl;
}
int main()
{
test("adm");
/*char a = 'b';
test(&a);*/
//test1(1);
int c[] = { 3,1,2,4,5 };
test1(c);
test2(c);
system("pause");
return 0;
}