672 views
0 0 votes
a and &a are the same thing where a is array name? I am unable to understand diff between  (a+1) and (&a+1) when assigned to a pointer
 
#include <stdio.h>
int main()
{
    int a[5] = {1,2,3,4,5};
    int *ptr = (int*)(&a+1);
    printf("%d %d", *(a+1), *(ptr-1));
    return 0;
}

Please log in or register to answer this question.

Position:
Show:

Related questions

0 0 votes
1 answers 1 answer
4.1k
4.1k views
debasree88 asked Apr 24, 2019
4,083 views
#include <stdio.h #include<stdlib.h int main() { //code char *ptr,s[]="debasree"; ptr=s[0]; printf("%s\n",*ptr); return 0; } I get this warning in geeks for...
0 0 votes
0 0 answers
369
369 views
rajinder singh asked Sep 2, 2018
369 views
What will be value inside an unintialized pointer eg case1:main(){Int *p;//local } Or case2:Int *p;// global Main(){}
0 0 votes
3 3 answers
2.2k
2.2k views
Nitesh Choudhary asked Jun 6, 2017
2,167 views
#include <stdio.h void swap(int *p, int *q) { int *t; *t=*p; *p=*q; *q=*t; printf("a=%d b=%d\n",*p,*q); } int main(void) { int a=5; int b=10; swap(&a,&b); printf("a=...
1 1 vote
3 answers 3 answers
1.5k
1.5k views
UK asked Mar 15, 2016
1,522 views
What is the difference when I write in program mynode * head; add_node(&head,10); add_node( struct node head, into value);To this mynode *head; add_node (head,10); add_...