title: 1.14 task in Kernighan, Ritchie "Programming with C" book
body: <p>I'm doing the task 1.14 in "The C Programming Language" book and don't know what's going wrong in my code, especially in printing the diagram.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  #define MAX 300
  
  int main(void) {
      int c,n,k,i,g,p,f;
      int mas[MAX];
  
      for(i = 0; i &lt; MAX; i++) //array for the string's length
          mas[i] = 0;
  
      i = 0;
      n = k = f = 0;
  
      //getting strings to print
  
      while((c = getchar()) != EOF) {
          n++;        //counter for each string in array
          if(c == '\n'){
              mas[i] = n;
              i++;
              if(n &gt; k){  //the highest number to print
                  k = n;
              }
              n = 0;
          }
      }
  
  //printing diagrams. I'm trying to do this:
  /*
    |
  k |
    |
    |
    |
    |_____________________
                i  
  */
  
      for(; k &gt; 0; k--){  //diagram's height
          for(g = 0; g &lt; i; g++){ //diagram's length
              if(mas[g] = k){     //if an array have an appropriate height to print
                  printf("%c", "#");
              } else
                  putchar(' ');   
          }
          putchar('\n');
      }
      return 0;
  }
  </code></pre>
  
  <p>You can get it in the ideone.com — <a href="http://ideone.com/1RZ1zU" rel="nofollow">http://ideone.com/1RZ1zU</a>.</p>