Hi all,
I'm an extreme novice (so please forgive me) and am trying to combine elements of an array into a single int variable. I have an array that is composed of numbers (0-3) and so would read something like:
032011320203010
I want to be able to take a group of three of those values and combine it into one. So I want to take the first three elements (0, 3, 2) and make it an int value 32. Or take the second set of three (0, 1, 1) and make it an int value 11.
I thought I could copy the three values into a character array and then use atoi to convert it into a single int, but it doesn't seem to be working (I get an int value of 0 instead of 32 for the first set).
This is what I have so far:
Code:int sequence[3*LENGTH]; int residue, i, j, nucleotide; char codon[3]; int realcodon; getnucleotidesequence(sequence); nucleotide = 0; i = nucleotide; for (j=0; j<3; j++) { codon[j] = (char)sequence[i]; ++i; } realcodon = atoi(codon);
Any help would be great appreciated!
Thanks so much,
Kayla