Addition of unsigned long and int in C

canbax
    int meta_size = 24;
    node_t* prev;

    printf("%lx, ", prev + meta_size );
    printf("%lx, ", prev); 
    printf("%lx, ", meta_size);

out put: 1519240, 1519000, 18 how this is happening?

Unimportant

Prev is a unitialised pointer, it contains (a random, because it is not initialised) memory address.

printf("%lx, ", prev + meta_size );//Prints the memory address prev is pointing to + (sizeof(node_t) * meta_size)
printf("%lx, ", prev);             //Prints the memory address prev is pointing to
printf("%lx, ", meta_size);        //Prints meta_size, 18 is 24 in hexidecimal, because of the 'x' in %lx 

However, the first 2 lines are undefined behaviour because pointers should be printed with %p

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

C - detect unsigned int overflow of addition

From Dev

What is the equivalent of unsigned long int in c#?

From Dev

Type conversion: signed int to unsigned long in C

From Dev

What is the equivalent of unsigned long int in c#?

From Dev

unsigned long long addition with multiple operands

From Dev

C++ signed and unsigned int vs long long speed

From Dev

C++ strange jump in unsigned long long int values

From Dev

Performance of int vs unsigned long long for prime number testing in C

From Dev

converting from unsigned long long to unsigned int

From Dev

unsigned int and unsigned long Xcode warnings in NSLogs

From Dev

Why (c++) casting from long long unsigned int to long double and back produces 0

From Dev

Why (c++) casting from long long unsigned int to long double and back produces 0

From Dev

Casting an unsigned long long int to signed long long int Is it possible?

From Dev

C unsigned int + int

From Dev

Unsigned long Int in Core data

From Dev

Arduino unsigned long int to char*

From Dev

C unsigned long long and imulq

From Dev

Is conversion int -> unsigned long long defined by the standard

From Dev

Strange unsigned long long int behavior

From Dev

narrowing conversion from int to long unsigned int {} is ill-formed in C++11

From Dev

Behavior of unsigned int in C

From Dev

C scanf unsigned long values

From Dev

How to convert an unsigned long int to QVariant

From Dev

make_signed<unsigned long>::type is int?

From Dev

Converting Const char * to Unsigned long int - strtoul

From Dev

Bitwise operations on unsigned long long in c

From Dev

Char array to unsigned long long in C

From Dev

Convert a string to a unsigned long long in c++

From Dev

Convert a string to a unsigned long long in c++

Related Related

  1. 1

    C - detect unsigned int overflow of addition

  2. 2

    What is the equivalent of unsigned long int in c#?

  3. 3

    Type conversion: signed int to unsigned long in C

  4. 4

    What is the equivalent of unsigned long int in c#?

  5. 5

    unsigned long long addition with multiple operands

  6. 6

    C++ signed and unsigned int vs long long speed

  7. 7

    C++ strange jump in unsigned long long int values

  8. 8

    Performance of int vs unsigned long long for prime number testing in C

  9. 9

    converting from unsigned long long to unsigned int

  10. 10

    unsigned int and unsigned long Xcode warnings in NSLogs

  11. 11

    Why (c++) casting from long long unsigned int to long double and back produces 0

  12. 12

    Why (c++) casting from long long unsigned int to long double and back produces 0

  13. 13

    Casting an unsigned long long int to signed long long int Is it possible?

  14. 14

    C unsigned int + int

  15. 15

    Unsigned long Int in Core data

  16. 16

    Arduino unsigned long int to char*

  17. 17

    C unsigned long long and imulq

  18. 18

    Is conversion int -> unsigned long long defined by the standard

  19. 19

    Strange unsigned long long int behavior

  20. 20

    narrowing conversion from int to long unsigned int {} is ill-formed in C++11

  21. 21

    Behavior of unsigned int in C

  22. 22

    C scanf unsigned long values

  23. 23

    How to convert an unsigned long int to QVariant

  24. 24

    make_signed<unsigned long>::type is int?

  25. 25

    Converting Const char * to Unsigned long int - strtoul

  26. 26

    Bitwise operations on unsigned long long in c

  27. 27

    Char array to unsigned long long in C

  28. 28

    Convert a string to a unsigned long long in c++

  29. 29

    Convert a string to a unsigned long long in c++

HotTag

Archive