Thread: Pointer to a structure

  1. #1

    Pointer to a structure

    How could I make a pointer to a structure?

    The structure name is New_Room

    I tried

    New_Room *cur_room=test_room;

    and a error saying "cannot convert type test_room from type New_Room to New_Room *"

    so I tried

    struct *cur_room=test_room;

    another conversion thing came up.

    int *cur_room=test_room;

    parse error came up.

    How in the bloody hell do you make a pointer to a structure? Can you even do this?

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Pointers hold addresses.

    New_Room *cur_room=&test_room;

  3. #3
    if (cur_room.items[itemTMP]==I_FLOWER)

    comes up with an error that says:

    Request for member 'items' in 'cur_room' which is of Non-Aggregate type 'New Room *'

    I tried it with the ampersand first, then I tried it like this.
    What is wrong?

    What the heck does Non-Aggregate mean anyway?

  4. #4
    S­énior Member
    Join Date
    Jan 2002
    I dunno you probably need to post some code but if my crystal ball is working try -

    if (cur_room->items[itemTMP]==I_FLOWER)

  5. #5
    It is working correctly Mr. Know-it-all!

    Say thank you, Rocky!

    Thank you!

  6. #6
    oh crud! I hit undo a few times and the code started screwing up. I am going to have a heck of a time sorting this crap out now!

    Thanks again, sorensen. You have helped me a BUNCH of times. I just wish I could help you sometime to pay you back, but I am still learning, so that is probably a slim chance...

    I am getting a C++ book and a C++ gaming book in a package, so I might stop asking easy questions. I forget which ones they are. They are both for windows, and they have source included. And when I get to be 14 (in July), I will get to work, and I'll try to save up for programming classes. But before I do the classes I should save up for MSVC++. I tried to D/L a pirated copy, but the file size was like 190 MB, and I get about 2k a second, at peek times (no kidding).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. method returning a pointer to a structure
    By nacho4d in forum C++ Programming
    Replies: 3
    Last Post: 05-25-2009, 10:01 PM
  2. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  3. how to cast a char *mystring to a structure pointer ??
    By hanhao in forum C++ Programming
    Replies: 1
    Last Post: 03-29-2004, 08:59 AM
  4. Pointer to structure problem
    By unregistered in forum C Programming
    Replies: 3
    Last Post: 12-24-2001, 07:54 AM
  5. Pointer to next Structure
    By Garfield in forum C Programming
    Replies: 6
    Last Post: 09-16-2001, 03:18 PM