title: Debug Assertion failed error with null terminated character array
body: <p>Trying to do an assignment when I try to compile the bottom code and I get the following debug assertion failed stub: </p>
  
  <p>File: f:\dd\vctools\crt\crtw32\convert\istype.c</p>
  
  <p>Line: 56</p>
  
  <p>Experession c >= -1 &amp;&amp; c &lt;= 255</p>
  
  <p>Several problems seem apparant with this error message. I don't even have an f drive or directory, and unless the line is being counted in the isctype.c program I don't have 56 lines in my code.</p>
  
  <p>The objective is to count the amount of words that the user enters. Check for spaces beforehand as well as null terminating characters.</p>
  
  <p>The code below has been fixed according to comments from other users</p>
  
  <pre><code>#include &lt;stdafx.h&gt;
  #include &lt;iostream&gt;
  #include &lt;string.h&gt;
  #include &lt;cctype&gt;
  
  using namespace std;
  
  int wordCount(int size, char wordArray[]);
  
  int main(){
      const int SIZE = 100;
      char wordArray[SIZE];
  
      cout &lt;&lt; "What is the string you wish to enter? ";
      cin.getline(wordArray, sizeof(wordArray));
  
      cout &lt;&lt; "The number of words entered is: " &lt;&lt; wordCount(strlen(wordArray), wordArray) &lt;&lt; endl;
  }
  
  int wordCount(int size, char wordArray[]){
  
      int charCount = 0, wordCount = 0;
  
      //counts the number of words in the entered string
      for (int i = 0; wordArray[i] != '\0'; i++){
          if (isalnum(wordArray[i])){
              charCount++;
              if (isspace(wordArray[i + 1])){
                  charCount = 0;
                  wordCount++;
              }
          }
      }
      return wordCount;
  }
  </code></pre>