You are on page 1of 2

// string3.cpp: Inputs and compares lines of text.

#include <iostream>
#include <string>
#include <conio.h>
using namespace std;
int main()
{
string line1, line2;
line1 = "aaaa bbbb cccc caaaa baaaab aaaa cccc";
line2 = line1;
int count = 0, decount = 0;
int location;
while (line1.find("aaaa") != -1)
{
location = line1.find("aaaa");
if (location == 0)
{
if (line1[location + 4] = ' ')
{ // True Alarm
cout << location + (count * 4)<< endl;
count = count + 1;
line1.erase(location,4);
line2.replace
}
else
{
count = count + 1;
line1.erase(location,4);
decount = decount + 1;
}
}
else if (line1[location - 1] == ' ' && line1.length() == location + 4)
{
cout << location + (count * 4)<< endl;
count = count + 1;
line1.erase(location,4);
}
else if (line1[location-1]==' ' && line1[location+4] == ' ')
{
cout << location + (count * 4)<< endl;
count = count + 1;
line1.erase(location,4);
}
else
{
count = count + 1;
line1.erase(location,4);
decount = decount + 1;
}

}
cout << "Total Count = " << count - decount;
_getch();
return 0;
}

You might also like