Trying to Search a Character Array for a word.

Hello,I'm trying to create a function that will accept a character array that the user enters a word or phrase that they want to find in another array that has already been entered.

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
int search(char searchInput[141]){

	
	cout << "Please enter search text(up to 140 characters): ";
	cin.ignore();
	cin.getline(searchInput, 141);
	bool found = true;
	int i;

	do
	{
		
		for (int i = 0; i<size(Text); i++)
		{
			for (int j = 0; j < size(searchInput); j++)
			{
				if (searchInput[j]!=Text[i])
				{
					found = false;
				}
				for (int i = 0; i < size(searchInput); i++)
				{
					if (Text[i] == searchInput[j])
					{
						found = true;
					}
				}
			
			}
			
		}


	} while (found != true);
	return i;
	cout << "The text was found at location" << i << endl;
	menu();


}
closed account (48T7M4Gy)
This might help:

http://www.cplusplus.com/reference/cstring/strcmp/

and/or:

http://www.cplusplus.com/reference/cstring/strstr/
Topic archived. No new replies allowed.