Passing pointer to array

This is a discussion on Passing pointer to array within the Windows Programming forums, part of the Platform Specific Boards category; I have an array of structs, how can I pass a pointer to it? I keep getting all sorts of ...

  1. #1
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293

    Passing pointer to array

    I have an array of structs, how can I pass a pointer to it? I keep getting all sorts of errors.

    I was thinking I should just have it like

    MYSTRUCT*mys[];
    mys = new MYSTRUCT[30];

    And pass it like that, but I tried that and my program shutdown immediately and gave no error!

  2. #2
    Registered User
    Join Date
    Feb 2004
    Posts
    127
    no.... this is wrong

    try the following

    Code:
    MYSTRUCT *mys=new MYSTRUCT[30];
    or

    Code:
    MYSTRUCT *mys;
    mys = new MYSTRUCT[30];
    hope it works

  3. #3
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293
    Ok it works, thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem passing pointer array
    By broli86 in forum C Programming
    Replies: 10
    Last Post: 06-30-2008, 12:27 PM
  2. Passing a pointer to two-dimension array in a function
    By E_I_S in forum C++ Programming
    Replies: 11
    Last Post: 06-19-2008, 10:57 AM
  3. Quick Pointer Question
    By gwarf420 in forum C Programming
    Replies: 15
    Last Post: 06-01-2008, 04:47 PM
  4. Compiler "Warnings"
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 04-24-2005, 02:09 PM
  5. Dynamic pointer array in C
    By MacFromOK in forum Windows Programming
    Replies: 14
    Last Post: 04-09-2005, 07:14 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21