Convert from double pointer to integer pointer

Discussion in 'C Programming' started by asker123, Jun 27, 2009.

  1. asker123

    asker123

    Joined:
    Jun 27, 2009
    Messages:
    1
    Likes Received:
    0
    There is a function that returns a pointer to a double array. I want to convert it to a pointer that points to an integer array because all the data that the function returns will be integers and I want to save memory.

    I tried to type cast it, but the problem is that the location of the consecutive elements are 8 bytes away because the function returns a pointer to a double. So even if I type cast the pointer the location of each element will not change.

    Is there a way for me to do this?

    I am trying to avoid having to copy one array to another array because I shall be using a large amount of data. But if it comes to that is there an efficient method to copy from a double* to an array to an int* to an array?

    Thanks
     
    asker123, Jun 27, 2009
    #1
    1. Advertisements

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. da Vinci
    Replies:
    5
    Views:
    8,978
    da Vinci
    Jul 31, 2004
  2. overbored
    Replies:
    5
    Views:
    9,400
  3. Sydex
    Replies:
    12
    Views:
    7,181
    Victor Bazarov
    Feb 17, 2005
  4. les ander
    Replies:
    4
    Views:
    1,177
    wes weston
    Oct 5, 2004
  5. Heiko Vogel
    Replies:
    3
    Views:
    772
    Method Man
    Sep 14, 2004
  6. rodrigo.gloria@gmail.com
    Replies:
    10
    Views:
    1,298
    rodrigo.gloria@gmail.com
    Mar 17, 2006
  7. lithiumcat@gmail.com

    pointer to integer to pointer conversions

    lithiumcat@gmail.com, May 6, 2008, in forum: C Programming
    Replies:
    11
    Views:
    628
    Richard Bos
    May 8, 2008
  8. Suresh V
    Replies:
    5
    Views:
    4,271
    SaticCaster
    Jul 5, 2010
Loading...