string problem

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
#include<iostream>
#include<string>

using namespace std;
int main()
{
	string s;
	cin>>s;
	int l=s.length();
	int count=0;
	for(int i=0;i<l;i+3)
	{
		if(s[i]!='S')
		{
			count++;
		}
		if(s[i+1]!='O')
		{
			count++;
		}
		if(s[i+2]!='S')
		{
			count++;
		}
	}
	cout<<count;
} 


My program is not printing the value of count..It is showing empty output..Why??
WELL I GOT MY MISTAKE IN THE LOOP INCREMENT PART. :)
Your for loop is wrong.
for(int i=0;i<l;i+3)
I guess you want to increment i by 3.
This should work:

for(int i = 0; i < l-3; i += 3)
Topic archived. No new replies allowed.