Here's a really simple problem. I understand the basic search algorithms however, is there a difference when implemeting them in regards to vectors or strings? I want to determine if a certain value using a sequential search, the code would look something like this;
#include <iostream>
#include <fstream>
#include <cstring>
#include <vector>
using namespace std;
int isPresent(string value);
int main()//start of the main funtion
{
string value;
string string;
cout <<"Enter a string";
cin >> string;
cout <<"Enter element to query";
cin>> value;
cout << isPresent(value);
system("PAUSE");
return EXIT_SUCCESS;
}
int isPresent(string value)
{
for (int i = 0; i < value.length()-1; i++)
{
if ( string[i] == value)
return false;
}
return true;
}
however a syntax error keeps occuring, I cant seem to find the problem,
thanks for your help!
in regards to implementing this in a class, the same problem arrises;
#include <vector>
#include <string>
#include <iostream>
using namespace std;
class LongString
{
private:
vector <string> contents;
public:
int isPresent(string value);