fork download
  1. /******************************************************************************
  2.  
  3. Welcome to GDB Online.
  4. GDB online is an online compiler and debugger tool for C/C++.
  5. Code, Compile, Run and Debug online from anywhere in world.
  6.  
  7. *******************************************************************************/
  8. #include <stdio.h>
  9.  
  10. // Function to calculate the sum of two integers
  11. void sum(void *a, void *b, void *c) {
  12. // Cast void pointers to int pointers and dereference them
  13. *(int *)c = *(int *)a + *(int *)b;
  14. }
  15.  
  16. int main() {
  17. int num1 = 5, num2 = 10, result;
  18.  
  19. // Call the function and pass the addresses of the variables
  20. sum(&num1, &num2, &result);
  21.  
  22. // Print the result
  23. printf("The sum of %d and %d is %d\n", num1, num2, result);
  24.  
  25. return 0;
  26. }
  27.  
  28.  
  29.  
Success #stdin #stdout 0s 5320KB
stdin
45
stdout
The sum of 5 and 10 is 15