need help asap

I am working on a sequence of RNA, I converted that sequence to string of int, I am trying to divide the string of intrna into parts of 3, use each to find the amino acid from a 3d array. but when I try to take paarts of 3 from intrna string, to store into int array, the ascii code gets stores and I can not get the char 0-3 out of intrna even though I tried type casting.



{string conin;
for (int s=0;s<rnaseq.length();s++)
{ if (rnaseq[s]=='U')
conin+='0';
else if (rnaseq[s]=='C')
conin+='1';
else if (rnaseq[s]=='A')
conin+='2';
else if (rnaseq[s]=='G')
conin+='3';
}
cout<<conin;
for (int i=0;i<conin.length()-2;i+=3)
{
if(conin.substr(i,3)=="203")
{cout<<"ki";

for (int l=i;l<conin.length()-2;l+=3)//if found
{
const int rkoto=3;
int ar[rkoto];

cout<<"hoise ";
for (int m=0;m<3;m++)
{
char rparina=(char)conin[l+m];
ar[m]=rparina;
cout<<ar[m]<<endl;;
}
//cout<<codonarray[conin[l]][conin[l+1]][conin[l+2]]<<endl;//correspondign letter isn prnted based on indice letter
}
}return conin;
}
Last edited on
I recently did this
for (int m=0;m<3;m++)
{

ar[m]= int(conin.substr(l+m,1));
cout<<ar[m]<<endl;;
}
I got this error
invalid cast from type ‘std::basic_string<char>’ to type ‘int’
ar[m]= int(conin.substr(l+m,1));
^
I am supposed to be able to covnert char to int right?
closed account (48T7M4Gy)
Best way is to use the tutorials here

http://www.cplusplus.com/reference/string/string/substr/

Yes you can interchange int and chars with the appropriate conversions which are very simple. A char is an int corresponding to the ASCII value of the character.
thanks i got it alhamdulillah
btw do you happen to know what the syntax would be lets say i get a argument in parameter and i use that argument as a physical file to open using ofstream
i was actually asking about command line argument
closed account (48T7M4Gy)
Maybe use this as a starting point. 'argument in a parameter' and 'argument as a physical file' is a little unclear.

http://www.cplusplus.com/doc/tutorial/files/
Topic archived. No new replies allowed.