• anonymous
Address to integer in C
Computer Science
  • Stacey Warren - Expert
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
  • jamiebookeater
I got my questions answered at in under 10 minutes. Go to now for free help!
  • anonymous
I need help converting an address of a variable to an integer value. What I tried so far was casting the address as so: (int)(&variable). While it works, I want to find another way to do this without it giving a warning.
  • anonymous
My guess is that `int` is not large enough to hold the value of the address, so you should use a sufficiently large data type like `uintptr_t`. You might be able to cast that to `int` without warning, but I don't know why you need to use an `int` in the first place.
  • rsmith6559
&variable is an unsigned integer by itself. If you have a 64bit machine ( you can put more than 4GB of RAM in it ), it may be too large for the C int data type which is usually a signed 32bit integer ( the 31st bit is used for the sign so the maximum value is a little over 2 billion ). I believe that an unsigned long int data type will handle an address fine.

Looking for something else?

Not the answer you are looking for? Search for more explanations.