logo
Course thumb

The C programming language made simple

Can you add or subtract two pointers?

#include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char* argv[]) { long long a = 15; long long b = 20; long long c[] = { 1, 2, 3 }; long long* p = malloc(sizeof(long long)); long long* q = malloc(sizeof(long long)); long long result = p - q; printf("Result is %lld with address %p and %p\n", result, p, q); return 0; }