title: How to pass strings from arrays to pointers while also using structures (in c)
body: <p>The point of this code is to read a string from the user (which is less than 50 characters) and then use the letters function to put the letters of the string in a pointer in such a way that each letter is going only once and then also counting the occurrence of each letter. Finally, with the use of report function it should output in the screen everything I just explained. For example,
  the user enters "Hello" the program outputs:</p>
  
  <pre><code>H : 1    
  e : 1    
  l : 2   
  o : 1    
  </code></pre>
  
  <p>The code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  struct charact {
      char ch;
      int occurs;
      struct charact *next;
  };
  
  typedef struct charact Char;
  typedef Char * ListofChar;
  typedef Char * CharNode_ptr;
  void letters(char name[50], ListofChar * chars_ptr);
  void report(ListofChar chars);
  Char * createnode(char ch);
  
  int main() {
      char name[50];
      ListofChar chars = NULL;
      scanf("%s", name);
      letters(name, &amp;chars);
      report(chars);
      return 0;
  }
  
  Char * createnode(char ch) {
      CharNode_ptr newnode_ptr ;
      newnode_ptr = malloc(sizeof (Char));
      newnode_ptr -&gt; ch = ch;
      newnode_ptr -&gt; occurs = 0;
      newnode_ptr -&gt; next = NULL;
      return newnode_ptr;
  }
  
  void letters(char name[50], ListofChar * lst_ptr) {
      int i;
      for(i=0; name[i]!='\0'; i++){
          //everything is done here
      }
      return;
  }
  
  void report(ListofChar chars) {
      int i;
      // this is only to output the results
      return;
  }
  </code></pre>
  
  <p>Thanks in advance</p>