title: How to compute the size of line or strings which consists of many words in c?
body: <blockquote>
    <p>I have written this code to differentiate between spaces and newline characters so that I can compute the length of the whole text from user input. I actually need to compute the length of the text so that I can allocate space for that length in a linked list. </p>
  </blockquote>
  
  <pre><code>char s[24];
  int l=0,i;
  scanf("%s",s);
  for(i=0;;){
      if(s[i]==' ') {
       l++;
       i++;
      }
      else if (s[i]=='\0') break;
      else {
      l++;
      i++;
      }
  }
  
  printf("%d",l);
  </code></pre>