// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <iostream>
#include <cstdlib>
#include <cstring>

using namespace std;

int search(char *s, char *ss)
{
    for(int i = 0; i < strlen(s)-strlen(ss) + 1; i++)
    {
        for(int j = 0; j < strlen(ss); j++)
        {
            if(s[i+j] != ss[j])
            {
                goto skip;
            }    
        }
        return i;
    skip:;
    }
    return -1;    
}    

int main(int argc, char *argv[])
{
  cout << search("abcdef", "cd") << endl;
  cout << search("abcdef", "xx") << endl;
  system("PAUSE");
  return 0;
}
