fork(3) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void test1()
  5. {
  6. int* ip1 = malloc(sizeof(int)*20);
  7. int* ip2 = ip1+10;
  8. printf("Diff in bytes: %d\n", (ip2-ip1)*sizeof(*ip1));
  9. printf("Diff in number of elements: %d\n", (ip2-ip1));
  10. }
  11.  
  12. int main()
  13. {
  14. test1();
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0s 2424KB
stdin
Standard input is empty
stdout
Diff in bytes: 40
Diff in number of elements: 10