Mail Archives: djgpp/1998/02/04/11:46:56
Matt Riker wrote:
> > the 'spritename' must be an int containing BLANK. If you need to use
> > different
> > values assign different ints to spritename.
>
> I could be just dumb :), but how can you but a string of letters into an
> int?
You should use another array where the names are stored and then use the
index.
You could do it like this for example:
char *spritenames[4] = {
"SPR1",
"SPR2",
"SPR3",
NULL
};
int foo(char *name)
{
int i;
for(i = 0; spritenames[i] != NULL; i++)
{
if(strcmp(spritenames[i], name) == 0)
return(i);
}
return(-1);
}
Now you know the index of the spritename and can use it to index into
your datafile array.
--
Bye,
Gerhard
email: gruber2 AT ibm DOT net
g DOT gruber AT sis DOT co DOT at
FIDO: Gruber_Gerhard AT 2:310/81.11
- Raw text -