I am trying to do a sequential string, but when I run my program I recieve three errors:the first one talks about 'searchList' : cannot convert parameter 3 from 'const char [4]' to 'std::string []
( I tried putting code tags by inserting my code between the

, but I am not positive if it is displaying) Sorry for any convenience!

#include <iostream>
#include <fstream>    

using namespace std;


int searchList(string array[], int, string value[]);
const int ARRAY_SIZE = 3;

int main()
{
	string someArray[ARRAY_SIZE] = {"mouse", "cat", "ant"};
	int results;
	results = searchList(someArray, ARRAY_SIZE, "ant");

	if (results == -1)
	cout << "You did not earn 100 points on any test\n";
	else
	{
	cout << "You earned 100 points on test ";
	cout << (results + 1) << endl;
	}
	return 0;
}
int searchList(string array[], int numElems, string value[])
{
	int index = 0; // Used as a subscript to search array
	int position = -1; // To record position of search value
	bool found = false; // Flag to indicate if the value was found
cout << "made it here" << endl;
	while (index < numElems && !found)
	{
		if (array[index] == value[]) // If the value is found
		{
			found = true; // Set the flag
			position = index; // Record the value's subscript
		}
		index++; // Go to the next element
	}
	return position; // Return the position, or -1
}

remove the brackets from the last parameter -- it should not be an array int searchList(string array[], int numElems, string value);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.