-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharray&pointer.c
32 lines (25 loc) · 1.06 KB
/
array&pointer.c
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
#include <stdio.h>
int main()
{
int arr[]= {1,2,3,4,5,6,7};
printf("Value at position 3 of the array is %d\n",arr[3]);
printf("The address of first element of the array is %d\n",&arr[0]);
printf("The address of first element of the array is %d\n",arr+1);
printf("The address of second element of the array is %d\n",&arr[1]);
printf("The value at address of first element of the array is %d\n",*(&arr[0]));
printf("The value at address of first element of the array is %d\n",*(arr+1));
printf("The value at address of second element of the array is %d\n",*(&arr[1]));
/*
int a=34;
char b='5';
int* pointera=&a;
char* pointerb=&b;
printf("%d\n",pointera);
printf("%d\n",pointera+1); //adds size of int (4 byte)
printf("%d\n",pointera-1); //subtract size of int (4 byte)
printf("%d\n",pointerb);
printf("%d\n",pointerb+1); //adds size of char (1 byte)
printf("%d\n",pointerb-1); //subtract size of char (1 byte)
*/
return 0;
}