Results 1 to 2 of 2

Thread: C++ Structure Help

  1. #1

    Thread Starter
    Banned
    Join Date
    Nov 2001
    Location
    USA
    Posts
    46

    Question C++ Structure Help

    Hello.

    The following is my structure which are used to get the user input:
    struct STATE
    { char *st[]
    int quantity
    }

    How can I pass the above structure to Function?
    And How can I access it in function? Using Pointer?

    Thank You

    Jacob

  2. #2
    jim mcnamara
    Guest
    Code:
    struct STATE 
    { char *st[]; 
       int quantity; 
    } 
    *STATEptr;
      
      STATEptr = malloc(sizeof(STATE);
     ..........
    
    // call a function
      myfunc(STATEptr);
    
    // define the function
    void myfunc(struct STATE *p){
            printf("%d\n",p->quantity);
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width