#define TOp_TEN 10
struct {
char *name[TOP_TEN];
int pks[TOP_TOP];
}
If you know there is 10, and there will always be 10, no need for a linked
list.
This assumed you strdup the players name.
If you want to strcpy it:
#define LEN 32
char name[TOP_TEN][LEN]
I would not use MAX_INPUT_LENGTH because it's overkill in size and wastes
memory.
-----Original Message-----
From: Jeremy Hill [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 28, 2002 3:55 PM
To: [email protected]
Subject: advice wanted
Greetings fellow ROM coders and enthusiasts.
In so making a table of, say, 'the top 10 player-killers', I have two
questions.
Question 1: What would be the easiest way of storing these players in a
structure?
For example:
The 'dumb' way:
struct {
char name1 [MAX_INPUT_LENGTH];
int name1pks;
char name2 [MAX_INPUT_LENGTH];
int name2pks;
char name3 [MAX_INPUT_LENGTH];
int name3pks;
....
} top_ten;
Or a smarter way, which I cannot think of offhand?
Question 2:
Based on this smarter method, how would you go about adding elements to the
list?
For instance, let's say you have a full 10 people on the list, and you need
to
add someone at position 7. You'd need to "shift" the remaining list down by
1,
drop off #10 to do so.
I most appreciate any guidance or help.
Thanks,
Jeremy Hill
--
ROM mailing list
[email protected]
http://www.rom.org/cgi-bin/mailman/listinfo/rom