Returning a struct pointer
        Posted  
        
            by idealistikz
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by idealistikz
        
        
        
        Published on 2010-04-24T02:10:30Z
        Indexed on 
            2010/04/24
            2:13 UTC
        
        
        Read the original article
        Hit count: 301
        
c
Suppose I have the following struct and function returning a pointer:
typedef struct {
  int num;
  void *nums;
  int size;
} Mystruct;
Mystruct *mystruct(int num, int size)
{
   ....
}
I want to define any Mystruct pointer using the above function. Should I declare a Mystruct variable, define the properties of Mystruct, assign a pointer to it, and return the pointer or define the properties of a mystruct property through a pointer immediately?
© Stack Overflow or respective owner