title: Function to save data as struct on C
body: <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  #include&lt;time.h&gt;
  
   typedef struct equipamento { 
      int codDipositivo;
      char nomeEquipamento[40];
      char newVar[50];
  }Equipamento;
  
  insert(int n, int cat, Equipamento eq[])
  {
      int codigo;
      char newVar[40];
      printf("\nNew Var: ");  
      scanf("%s",&amp;newVar);    
      eq[n].codDipositivo=newVar;
  }
  
  main()
  {
      Equipamento equipamento[MAX_EQ_DSP];
  
  
      ...a bunch of scanfs 
      scanf("%d",&amp;n);
      scanf("%d",&amp;pr);
  
  
      insert(n, pr, equipamento);
  }
  </code></pre>
  
  <p>This is a sample of what I have.</p>
  
  <p>on <strong>main</strong> I have a bunch of scanfs which will update the data showing on the screen but now I want to pass that data into a structure and ask for additional information.</p>
  
  <p>I'm trying to use the updated code but for some reason, instead of 39 chars, it breaks down (returns to the main cycle) after the first char</p>
  
  <pre><code>printf("\nNome do Equipamento: "); 
  gets(nome);
  strcpy(eq[n].nomeEquipamento, nome);
  </code></pre>