Filestream and array

I am Trying to get a file that has codon/amino data
uuu phe
uua phe

^^ in that form.
I am trying to put the file into an array so each element reads in a amino or codon uuu or phe not the entire line together. Then I try to take the array and split it into two different arrays one for codons and one for amino.

However when I make the first array it reads in two
1
2
3
4
5
6
7
8
9
10
11
12
13
		while (!CodonAmino.eof())
			
		{
			
			getline(CodonAmino,AminoCodon[a],' ');
			cout <<AminoCodon[a]<<endl;
			a++;
			
		}
	}




That is what I have for the first array. It read it a[0]=uuu a[1]= phe uua


Someone please help :(
Last edited on

this is because the phe and uua are not seperated by a ' ' but by a '\n' (new line character).
if i use \n then it will put the entire line into each element. Each line has uuu phe .(two separate codons and amino.)

I suggest you read each line using a \n and than write a function which can create tokens from that line with the given character.

Topic archived. No new replies allowed.