/*
5. Write a function, char* findx(const char* s, const char* x), 
that finds the first occurrence of the C-style string x in s.*/

#include <iostream>
using namespace std;

#define MAXLENGTH 10000

const char* findx(const char* s, const char* x) {
	int i{ 0 };
	while(*s) {
		i = 0;
		while (x[i] == *s) {
			++i;
			++s;
		}
		if (x[i]=='\0') return x;
		++s;
	}
	return "";
}

int main() {
	cout << "Enter two strings: ";
	char* cstr1 = new char[MAXLENGTH];
	char* cstr2 = new char[MAXLENGTH];
	while (cin) {
		cin.getline(cstr1, MAXLENGTH);
		cin.getline(cstr2, MAXLENGTH);
		cout << findx(cstr1, cstr2);
		cout << "\nEnter two strings: ";
	}
	delete[] cstr1;
	delete[] cstr2;
}