Fixing cast from pointer to integer of different size

A

Arenlor

I'm wondering if there is a way to fix this, as no where online is
there anything about it. I have a char[] that I want to cast to an int.
 
N

nicolas.sitbon

I'm wondering if there is a way to fix this, as no where online is
there anything about it. I have a char[] that I want to cast to an int.

intptr_t or uintptr_t are preferred.
 
A

Arenlor

I'm wondering if there is a way to fix this, as no where online is
there anything about it. I have a char[] that I want to cast to an int.

intptr_t or uintptr_t are preferred.

Cool, fixed it, didn't realize I'd have to include a whole new
library, but it works.
 
C

Chris Dollin

Arenlor said:
I'm wondering if there is a way to fix this, as no where online is
there anything about it. I have a char[] that I want to cast to an int.

/Why/ do you want to cast a char[] (more likely, a char*) to an int?

Perhaps there's a better answer to the bigger problem.
 
R

RjY

Arenlor posted:
I'm wondering if there is a way to fix this, as no where online is
there anything about it. I have a char[] that I want to cast to an int.

Try intptr_t, from stdint.h, instead of int.
 
K

Keith Thompson

Arenlor said:
I'm wondering if there is a way to fix this, as no where online is
there anything about it. I have a char[] that I want to cast to an int.

What are you trying to accomplish?

You have some problem that you're not telling us about. Casting a
pointer to an integer is a solution to that problem, not a goal in
itself -- and it may be the wrong solution.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top