-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpointer_and_array.cpp
More file actions
33 lines (25 loc) · 836 Bytes
/
Copy pathpointer_and_array.cpp
File metadata and controls
33 lines (25 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <conio.h>
using namespace std;
int main(){
int array[] = {10,20,30,40,50};
cout << array << endl; // output : 0x61fefc
cout << &array[0] << endl;// output : 0x61fefc
cout << array[0] << endl;// output : 10
cout << *array << endl; // output : 10
int number[] = { 12 , 34 , 56 , 78 , 90 };
int loop;
for (loop = 0 ; loop < 5 ; loop++){
cout << "Addrees of array " << loop << " = " << &number[loop] << endl;
cout << "Addrees of array " << loop << " = " << number+loop << endl;
cout << endl;
cout << "value of array " << loop << " = " << number[loop] << endl;
cout << "value of array " << loop << " = " << *(number+loop) << endl;
cout << endl;
}
int *pointer = number;
// number ++ (invalid)
// pointer ++ (valid)
cout << *pointer << endl;
// output : 12 ( first array )
getch();}