Thread: Array of structs -> struct to void

  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    2

    Array of structs -> struct to void

    Hi all,

    I have this struct:
    Code:
    typedef  struct {
        U16 size;
        void *str;
    } test_t;
    And I have this array:
    Code:
    test_t get[2] = {
        {sizeof(test1_t), (test1_t *)malloc(sizeof(test1_t))},
        {sizeof(test2_t), (test_t *)},
    };
    So I need to get a different pointer according array position.
    But It is wrong, could you tell me how to do this?
    Thanks a lot.
    []'s

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by v1n1c1u5 View Post
    But It is wrong, could you tell me how to do this?
    I honestly do not understand your question. Can you explain what you mean any better?
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  3. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM
  4. Quack! It doesn't work! >.<
    By *Michelle* in forum C++ Programming
    Replies: 8
    Last Post: 03-02-2003, 12:26 AM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM