Answer:
Array name is constant pointer which points to base address of an array. While pointer to that array points to base address of that array.
First difference:
(a) Incrementing array name
(b) void main(){
(c) int arr[]={1,2,3,4};
(d) arr++;
(e) printf("%d",*arr);
(f) }
(g) Output: Compilation error
(h) (b)Incrementing pointer to array
(i) void main(){
(j) int arr[]={1,2,3,4};
(k) int *ptr=arr;
(l) ptr++;
(m) printf("%d",*ptr);
(n) }
(o) Output: 2
(p) Second difference:
(q) void main(){
(r) int arr[]={1,2,3,4};
(s) int *ptr=arr;
(t) printf("%d %d",sizeof(arr),sizeof(ptr));
(u) }
Output: 8 2
No comments:
Post a Comment