Thread: struct question

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    12

    struct question

    One quick question... probably easy, I'm just a little confused.

    Code:
    struct sword_class
    {
    	char name[15];
    	int damage;
    	int price;
    };
    
    sword_class swordz[3] = {
    {"Short Sword", 6, 50},
    {"Long Sword", 8, 100},
    {"Dagger", 3, 10}};
    If you can, how would you for example be able to print to the screen a part of this {"Short Sword", 6, 50}, would I be able to output the price separately from the others?

    Thanks in advance,
    -Psycho

  2. #2
    Registered User
    Join Date
    Jun 2002
    Posts
    151
    Yes, with -

    cout << swordz[0].price;

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    12
    ohhhh

    thanks again
    -Psycho

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with linked list sorting function
    By Jaggid1x in forum C Programming
    Replies: 6
    Last Post: 06-02-2009, 02:14 AM
  2. Struct question... difference between passing to function...
    By Sparrowhawk in forum C++ Programming
    Replies: 6
    Last Post: 02-23-2009, 03:59 PM
  3. Looking for a way to store listbox data
    By Welder in forum C Programming
    Replies: 20
    Last Post: 11-01-2007, 11:48 PM
  4. struct question
    By caduardo21 in forum Windows Programming
    Replies: 5
    Last Post: 01-31-2005, 04:49 PM
  5. towers of hanoi problem
    By aik_21 in forum C Programming
    Replies: 1
    Last Post: 10-02-2004, 01:34 PM