title: Ppointer and data structure
body: <p>My goal is to create a push function for my data structure.</p>
  
  <p>What I'm trying to do:</p>
  
  <ol>
  <li>ask a client to enter a three character obj word eg. box</li>
  <li>the obj name will then be passed to the push function(for now the head and tail pointer's are null)</li>
  <li>the computer will then allocate memory for this, and then the function will return a memory address</li>
  <li>I will then use that address to store the obj name to my object Array.</li>
  </ol>
  
  <p>I'm trying to do this data structure step by step, and as for now I cannot seem to save the obj name to the objArray. Can I not return a pointer?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  char *push(char element, char *head, char *tail){
      char *dq;
      dq = (char*)malloc(4*sizeof(char));
      head=dq;
      return head;
  }
  
  int main(){
      char input[7];
      char command[7];
      char objArr;
      char objname[4];
      char *head;
      char *tail;
  
  while(printf("Choose from the ff operations by typing:\npush\npop\ninject\neject\nexit\nInput Command: ")&amp;&amp;fgets(input, 6, stdin)){
      sscanf(input, "%s", command);
  
      if(strcmp(command, "exit")==0){
          break;
      }
      if(strcmp(command, "push")==0){
          printf("Input an object name to push: ");
          fgets(objname, 4, stdin);
  
          head = push(objname, *head, *tail);
          objArr[head] = objname;
          printf("%s", objArr[head]);
          break;
      }
  
      if(strcmp(command, "pop")==0){
          break;
      }
  
      if(strcmp(command, "inject")==0){
          break;
      }
  
      if(strcmp(command, "eject")==0){
          break;
      }
  
  }
  
  }
  </code></pre>