title: Using Pointers to pass C-String arguments
body: <p>I have been stuck on this program all day. I finally feel like I'm getting really close. I have to find the number of vowels and characters in a string. Then output them at the end. However, when I compile my program crashes. I have checked syntax and looked in my book all day. If anyone can help I would really appreciate it! because I have 5 more similar functions to write that manipulate c-strings. Thanks!</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  int specialCounter(char *, int &amp;);
  
  
  int main()
  {
  
  const int SIZE = 51;        //Array size
  char userString[SIZE];      // To hold the string
  char letter;
  int numCons;
  
  
  
  // Get the user's input string
  cout &lt;&lt; "First, Please enter a string (up to 50 characters): " &lt;&lt; endl;
  cin.getline(userString, SIZE);
  
  
  
  
  
  // Display output
  cout &lt;&lt; "The number of vowels found is " &lt;&lt; specialCounter(userString, numCons) &lt;&lt;      "." &lt;&lt; endl;
  cout &lt;&lt; "The number of consonants found is " &lt;&lt; numCons &lt;&lt; "." &lt;&lt; endl;
  
  
  }
  
  
  
  int specialCounter(char *strPtr, int &amp;cons)
  {
  int vowels = 0;
  cons = 0;
  
  
  while (*strPtr != '/0')
  {
      if (*strPtr == 'a' || 'A' || 'e' || 'E' || 'i' || 'I' || 'o' || 'O' || 'u' || 'U')
      {
          vowels++;       // if vowel is found, increment vowel counter
                      // go to the next character in the string
      }
      else
      {
          cons++;         // if consonant is found, increment consonant counter
                      // go to the next character in the string
      }
  
      strPtr++;
  
  }
  return vowels;
  
  }
  </code></pre>