title: Linear Search in a Char Array -- C++ (Visual Studio 2005)
body: <p>I am very new to C++ programming and you will see why.</p>
  
  <p>I want to make a character array consisting of a few words that I want to search with a linear search function. Does this array have to be a two-dimensional array? For example:</p>
  
  <pre><code>char Colors[3][6] = {"red", "green", "blue"};
  </code></pre>
  
  <p>I tried it like this:</p>
  
  <pre><code>char Colors[] = {"red", "green", "blue"};
  </code></pre>
  
  <p>This gave me a "too many initializers" error.</p>
  
  <p>I assume the 1st method is correct because it states the amount of elements in the array and the maximum length of an element, correct?</p>
  
  <p>Now how would I implement a linear search function to find a word inside that array? Can I do something like the following:</p>
  
  <p>(Assuming the linearSearch function has already been declared)</p>
  
  <pre><code>char searchKey;  
  char element;
  
  char Colors[3][6] = {"red", "green", "blue"};
  
  printf("Enter the color to look for: \n");
  
  scanf("%s", searchKey);
  
  element = linearSearch(Colors, searchKey, ??); //?? is where I don't know what to enter
  
  if (element != -1)  
  {  
      printf("Found the word.\n");  
  }  
  else  
  {  
      printf("Didn't find the word.\n");  
  }
  </code></pre>
  
  <p>Is this possible? If so, what would the declaration look for the linearSearch function? I hope I provided enough information for this to be somewhat usable.</p>
  
  <p>edit: Thanks all for the help, got the program working as intended.</p>