-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpointers.cpp
More file actions
62 lines (49 loc) · 1.21 KB
/
pointers.cpp
File metadata and controls
62 lines (49 loc) · 1.21 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
using namespace std;
void print(int *p)
{
// cout<<&p<<endl;
cout<<p<<endl;
}
void update(int *p)
{
p=p+1;
cout<<p<<endl;
}
// important thing is ://///arr[i]=*(i+arr); and i[arr]=*(i+arr);
int getSum(int *arr,int size)
{
cout<<sizeof(arr)<<endl;
int s=0;
for(int i=0;i<size;i++)
{
// s+=i[arr];
s+=arr[i];
}
return s;
}
int main()
{
// cout<<"Hello World";
// char temp[6]="abcde";
// char *c="abcde";
// c[0]='f';
// cout<<c<<endl;
// cout<<c[1]<<endl;
// char *p=&c;
// cout<<temp<<endl;
// int i=9;
// int *p=&i;
// print(p);
// update(p);
// print(p);
int arr[6]={1,2,3,45,5,7};
// cout<<getSum(arr,6)<<endl; ///////with this we can take part of an array
cout<<getSum(arr+3,3)<<endl;
return 0;
}