Fixing cast from pointer to integer of different size

Discussion in 'C Programming' started by Arenlor, Jul 30, 2009.

  1. Arenlor

    Arenlor Guest

    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.
    Arenlor, Jul 30, 2009
    #1
    1. Advertising

  2. On 30 juil, 10:22, Arenlor <> wrote:
    > 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.
    nicolas.sitbon, Jul 30, 2009
    #2
    1. Advertising

  3. Arenlor

    Arenlor Guest

    On Jul 30, 4:24 am, "nicolas.sitbon" <> wrote:
    > On 30 juil, 10:22, Arenlor <> wrote:
    >
    > > 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.
    Arenlor, Jul 30, 2009
    #3
  4. Arenlor

    Chris Dollin Guest

    Arenlor wrote:

    > 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.

    --
    "It is seldom good news." ~Crystal Ball~, /The Tough Guide to Fantasyland/

    Hewlett-Packard Limited Cain Road, Bracknell, registered no:
    registered office: Berks RG12 1HN 690597 England
    Chris Dollin, Jul 30, 2009
    #4
  5. Arenlor

    RjY Guest

    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.

    --
    http://rjy.org.uk/
    RjY, Jul 30, 2009
    #5
  6. Arenlor <> writes:
    > 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.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
    Keith Thompson, Jul 30, 2009
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rocke Robertson
    Replies:
    14
    Views:
    12,968
    Dan Pop
    Oct 2, 2003
  2. Markus Dehmann
    Replies:
    14
    Views:
    916
    Irrwahn Grausewitz
    Jun 28, 2004
  3. Dawn Minnis
    Replies:
    4
    Views:
    1,517
    Dawn Minnis
    Feb 20, 2005
  4. Replies:
    2
    Views:
    1,214
    Martin Ambuhl
    Apr 1, 2005
  5. Juggernaut
    Replies:
    10
    Views:
    1,582
    CBFalconer
    Apr 9, 2005
Loading...

Share This Page