fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int v[5] = {10, 20, 30, 40, 50};
  5. int *v1Ptr, *v2Ptr;
  6.  
  7. v1Ptr = &v[1];
  8. v2Ptr = &v[2];
  9.  
  10.  
  11. printf("The address of v1Ptr in Hex is %p and in DEC is %lu\n",
  12. (void*)v1Ptr, (unsigned long)(v1Ptr));
  13. printf("The address of v2Ptr in Hex is %p and in DEC is %lu\n",
  14. (void*)v2Ptr, (unsigned long)(v2Ptr));
  15.  
  16. printf("The result of v2Ptr - v1Ptr is %d\n", (int)(v2Ptr - v1Ptr));
  17.  
  18. // ขนาดของ int
  19. printf("Size of integer is %zu bytes\n", sizeof(int));
  20. return 0;
  21. }
Success #stdin #stdout 0.03s 26212KB
stdin
Standard input is empty
stdout
#include <stdio.h>

int main(void) {
    int v[5] = {10, 20, 30, 40, 50};
    int *v1Ptr, *v2Ptr;

    v1Ptr = &v[1];  
    v2Ptr = &v[2];  

   
    printf("The address of v1Ptr in Hex is %p and in DEC is %lu\n",
           (void*)v1Ptr, (unsigned long)(v1Ptr));
    printf("The address of v2Ptr in Hex is %p and in DEC is %lu\n",
           (void*)v2Ptr, (unsigned long)(v2Ptr));

    printf("The result of v2Ptr - v1Ptr is %d\n", (int)(v2Ptr - v1Ptr));

    // ขนาดของ int
    printf("Size of integer is %zu bytes\n", sizeof(int));
    return 0;
}