// Locate a sub strings position
// By DreamVB 19:38 06/10/2016 

#include <iostream>

using namespace std;
using std::cout;
using std::endl;

void StrIndexOf(string s0, string s1){
	int len0 = s0.length();
	int len1 = s1.length();
	
	int i = 0;
	int j = 0;
	int k = 0;

	for (i = 0; i < (len0 - len1)+1; i++){
		for (j = 0; j < len1; j++){
			//If string not equal exit
			if (s0[i + j] != s1[j]){
				break;
			}
		}
		//Check string length
		if (j == len1){
			//Print out positionn found.
			cout << s1.c_str() << " was found at index: " << i << endl;
		}
	}
}

int main(int argc, char *argv[]){
	string s0 = "today I took a long walk in the park the weather was fantastic.";
	cout << "String to test: " << endl << s0.c_str() << endl << endl;
	StrIndexOf(s0.c_str(), "the");
	StrIndexOf(s0.c_str(), "walk");
	system("pause");
	return 0;
}