abort()

hello, i was writing a program about substrings and when i compiled it it said :

R6010
- abort() has been called


here is the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# include<iostream>
# include <cmath>
# include <algorithm>
# include <string>
# include <stdio.h>
using namespace std;
int main()
{
	int TTT=0,TTH=0,THT=0,THH=0,HTT=0,HTH=0,HHT=0,HHH=0;
	string str;
	string a1="TTT",a2="TTH",a3="THT",a4="THH",a5="HTT",a6="HTH",a7="HHT",a8="HHH";
	int t,n,j;
	cin>>t;
	for (int i=0;i<t;i++)
	{
		TTT=0;TTH=0;THT=0;THH=0;HTT=0;HTH=0;HHT=0;HHH=0;
		cin>>n>>str;
		j=str.length()-3;
		for (int x=1;x<j;i++)
		{
		 if (str.substr(i,3)==a1)
			 TTT++;
		 else if (str.substr(i,3)==a2)
			 TTH++;
		 else if (str.substr(i,3)==a3)
			 THT++;
		 else if (str.substr(i,3)==a4)
			 THH++;
		 else if (str.substr(i,3)==a5)
			 HTT++;
		 else if (str.substr(i,3)==a6)
			 HTH++;
		 else if (str.substr(i,3)==a7)
			 HHT++;
		 else if (str.substr(i,3)==a8)
			 HHH++;
		}
		cout<<n<<" "<<TTT<<" "<<THT<<" "<<THH<<" "<<HTT<<" "<<HTH<<" "<<HHT<<" "<<HHH<<endl;
	}
}





any idea what is that and how to solve it?
thanks very much and sorry for bothering you.
in your substr() functions you're using i, but I guess you want to use x

and you increase i on line 19. Is this intended?
ohh! what an idiot i am! sorry for bothering you and thanks very much
no problem, typos happens to everyone
Topic archived. No new replies allowed.