55. Add Two Integers Using Void Pointers

Back To All Submissions
Previous Submission
Next Submission

Code

#include <stdio.h>

int add_two_void_pointers(void *a, void *b) {
    // Your logic here
    int arg1 = *(int *)a;
    int arg2 = *(int *)b;
    return arg1 + arg2;
}

int main() {
    int x, y;
    scanf("%d %d", &x, &y);

    int result = add_two_void_pointers(&x, &y);
    printf("%d", result);

    return 0;
}

Solving Approach

Recast the void into another variables
 

Was this helpful?
Upvote
Downvote