Well, it's been a lonngg time since I've last been on DaniWeb and everything looks different. Anyway, I'm having a bit of a brain fart I suppose so I'm hoping someone can help me out. I've been working on this program that basically reads in a fasta file with multiple sequences and breaks it up. I've had it so that it can spit it out into multiple files, then I changed it to use dynamically allocated memory and an array of my "sequence" objects and now i just display the results on the screen. Now I want to make an educated guess as to whether each sequence is dna, rna, or a peptide and store it as an enumerated type in the sequence structure. I think I have part of it correct as far as adding an enum to my struct. However, I'm lost as to how to access it in my sequence object. Below is a snippet of what i have:

typedef struct { char *accession; char *data; enum {RNA, DNA, PEP} seqType;} Sequence ;

Sequence newSequence( char *acc, char *data)
        Sequence returnSeq ;

        returnSeq.accession = (char *) malloc( ( strlen( acc ) + 1 ) * sizeof( char ) ) ;

        strcpy( returnSeq.accession, acc ) ;

        returnSeq.data = (char *) malloc( ( strlen( data ) + 1 ) * sizeof( char ) ) ;

        strcpy( returnSeq.data, data ) ;

        return returnSeq ;

Any help is greatly appreciated.

6 Years
Discussion Span
Last Post by NitaB

returnSeq.seqType = RNA;

Actually, that compiles just fine. I thought I would need to somehow add it to my parameter list for newSequence but I'll keep going and see what happens.


Sooo, I continued on with the rest of my code and all I keep getting at the end is the initialized value. I cannot seem to modify it through main.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.