I have an issue. I would like to insert the result of substr function into the array, but it reads my string not from the beggining to the end but it omits the big part of it and starts to read at the end. And it doesn't put the reult in the array correctly - every array cell contains the same substring I'm using structures. Here is the part of my code, the input looks like that:
TTGATTCTATGGAGGGATGCTGGCAAGGCTCCGGAAGCAGCATCAGCAATTAAAAAATTACTGGACCTGATCTT
And the code
struct sekwencja
struct sekwencja
{
string sekwencja;
string etykieta[10000];
int jakosc[200];
int dlugosc;
string idf;
string idq;
}sek[100];
(...)
sek[i].dlugosc=sek[i].sekwencja.length();
(...)
cout<<"give the length of substring"<<endl;
cin>>h;
for (int i=0;i<7;i++)
{
for (int a=1; a<sek[i].dlugosc-1; a++)
{
if(sek[i].sekwencja.substr(a,h).length()==h){
for(int b=0;b<sek[i].dlugosc-1+h;b++)
{
sek[i].etykieta[b]=sek[i].sekwencja.substr(a,h);
}
}
}
}
I would be very grateful for your help!
EDIT:
I don't know why I can do something like this:
int b=0;
string etykieta [1000];
for (int i=0;i<7;i++)
{
for(int a=0;a<sek[i].dlugosc;a++)
{
etykieta[b]=sek[i].sekwencja.substr(a,h);
b++;
}
}
but not like this
int b=0;
string etykieta [1000];
for (int i=0;i<7;i++)
{
for(int a=0;a<sek[i].dlugosc;a++)
{
sek[i].etykieta[b]=sek[i].sekwencja.substr(a,h);
b++;
}
}
std::vector?struct sekwencja { string sekwencja; string etykieta[1000]; int jakosc[200]; int dlugosc; string idf; string idq; }sek[100];I'm not using vector because at the end of my program I have to give an information from which sequence (there are 7 of them in the file) the substring comes from