Using scanf with enum types
Hi all,
I've got my own enum type set up as follows
Code:
typedef enum aa
{
a= 0, ala= 0, alanine= 0,
r= 1, arg= 1, arginine= 1,
n= 2, asn= 2, asparagine= 2,
d= 3, asp= 3, aspartic_acid= 3,
c= 4, cys= 4, cysteine= 4,
q= 5, gln= 5, glutamine= 5,
e= 6, glu= 6, glutamic_acid= 6,
g= 7, gly= 7, glycine= 7,
h= 8, his= 8, histidine= 8,
i= 9, lle= 9, isoleucine= 9,
l= 10, leu= 10, leucine= 10,
k= 11, lys= 11, lysine= 11,
m= 12, met= 12, methionine= 12,
f= 13, phe= 13, phenylalanine= 13,
p= 14, pro= 14, proline= 14,
s= 15, ser= 15, serine= 15,
t= 16, thr= 16, threonine= 16,
w= 17, trp= 17, tryptophan= 17,
y= 18, tyr= 18, tyrosine= 18,
v= 19, val= 19, valine= 19
} aa;
And now I'd like to use scanf to read a line and store one part of it as this datatype aa.
The data I'm reading in takes the format of integercharacter, such as 19a, 23c, 243q, etc.
Currently I'm reading it in as follows
Code:
int focal_position;
char focal_amino_acid;
if (sscanf(string, "%d%c", &focal_position, &focal_amino_acid)!=2)
{
printf("could not read in data from string in function tokenizer()\n");
exit(255);
}
i.e. I'm reading in the a in 19a (for example) as a character, but I'd prefer to read it in as this enum type. Is there easy way to do that?
Thanks,
Brad