+ 1

Is that possible to add pointers to each other?

Pointer

16th Jan 2020, 1:21 PM
Pravesh Maurya
Pravesh Maurya - avatar
2 Respuestas
+ 3
Pravesh Maurya Yes you can do so I'll tell you the easy way. int first, second, *p, *q, sum; printf("Enter two integers to add\n"); scanf("%d%d", &first, &second); p = &first;//first pointer to store value q = &second;//second pointer to store value sum = *p + *q; printf("Sum of entered numbers = %d\n", sum); return 0;
16th Jan 2020, 1:28 PM
DishaAhuja
DishaAhuja - avatar
+ 1
the first answer is for values they point to, you can also add two pointers to get the sum of their addresses following on the code above : printf("%p", (int)p + (int)q) ;
16th Jan 2020, 1:34 PM
Bahhaⵣ
Bahhaⵣ - avatar