title: Working with Char in c programming
body: <p>I am a newbie in c programming language and I have a university tutorial assignment that is related with working with chars(I wont be graded for this assignment) where you have to count words, I have to compile and submit my answers in an online web environment where my code will run against test cases that are not visible to me.here is my assignment:</p>
  
  <blockquote>
    <p>Write the function 'wc' which returns a string containing formatted as follows: "NUMLINES NUMWORDS NUMCHARS NUMBYTES" . 
    Whitespace characters are blanks, tabs (\t) and new lines (\n). A character is anything that is not whitespace. The given string is null-char (\0) terminated.</p>
  </blockquote>
  
  <p>here is my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  char* wc(char* data) {
    char* result ;
    int numLine ;
    int numWords ;
    int numChars ;
    int i;
    int numBytes =strlen(data);
    char* empty=NULL;
    while(strstr(data,empty)&gt;0){
      numWords=1;
  
      for (i = 0; i &lt; sizeof(data); i++) {
  
      if(data[i]=='\n'){
       numLine++;
     }
      if(data[i]==' ' ){
       numWords++;
     }
      if(data[i]!=' '){
       numChars++;
     }
     }
  
     }
  
      sprintf(result, "%d %d %d %d", numLine, numWords, numChars, numBytes);
      return result;
  }
  </code></pre>
  
  <p>this code will give me the correct output result but I am missing something here at least the test tells me that.</p>