dumb text game :P

This is a discussion on dumb text game :P within the C++ Programming forums, part of the General Programming Boards category; Code: my structure: void opendrawer(void); struct itemgot { char notepad[]; }; my not working part of my program: void opendrawer(void) ...

  1. #1
    Rad gcn_zelda's Avatar
    Join Date
    Mar 2003
    Posts
    942

    Angry dumb text game :P

    Code:
    my structure:
    
    void opendrawer(void);
    
    struct itemgot
    {
        char notepad[];
    };
    
    my not working part of my program:
    
    void opendrawer(void)
    {           /*line 83*/
        struct itemgot items;
        cout << "You opened the drawer. There is a notepad inside, which you take out" << endl;
        items.notepad=1;/*Line 86*/
    }
    errors: Parse error before '{' token on line 82
    items undeclared on 86

  2. #2
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    When your instantiating an object in C++ (struct/class), you don't need the word struct/class.

    Line 84 should be somethin' like this:
    itemgot items; // No 'struct'

    That should take care of the second error. I can't figure out the first one from the given code though. Usually when you get those "Parse error before ..." messages, your error is actually a few lines up, and is something along the lines of a missing comma or semi-colon.

    Also, you might want to give 'notepad' a starting size. i.e.:

    char notepad[20];

    The last line probably does not do what you want it to either. It is trying to assign the pointer 'notepad' to memory address 1. Chances are you want something like strcpy(notepad, "1").
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  3. #3
    Rad gcn_zelda's Avatar
    Join Date
    Mar 2003
    Posts
    942
    Oh yeah, thanks. I forgot that arrays are pointers :P

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. text based mmo type game.....
    By SONAR in forum Game Programming
    Replies: 0
    Last Post: 12-09-2008, 04:17 AM
  2. How to use FTP?
    By maxorator in forum C++ Programming
    Replies: 8
    Last Post: 11-04-2005, 02:17 PM
  3. My Memory Game
    By jazy921 in forum C Programming
    Replies: 0
    Last Post: 05-05-2003, 05:13 PM
  4. My Pre-Alpha Version Rpg Text Game
    By knight543 in forum C++ Programming
    Replies: 1
    Last Post: 04-06-2002, 05:02 AM
  5. Text Based Game
    By drdroid in forum C++ Programming
    Replies: 2
    Last Post: 02-18-2002, 05:21 PM

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