title: Scanning Multiple inputs from one line using scanf
body: <p>I'm trying to scan in a single line input and storing it in a struct. I'm not sure if I am storing it wrong or I am printing it wrong. I'm not sure on how to use <code>scanf</code> with <code>for</code> loops since I never done it before not to mention C likes to overwrite stuff. So I wasn't sure on how to approach this. </p>
  
  <p>This is something I put together but when I print I get junk numbers. I was intending to maybe use pointers but my professor won't let us use it. Which is why I'm having trouble.</p>
  
  <p><strong>EDITED</strong></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  
  #define MAX 3
  #define MAXTRIP 6
  
  
  struct stop
  {
    float cost;
    float time; 
  };
  
  struct trip
  {
    char Dest_letter;
    int stop_num;
    struct stop leg[MAX];
  };
  
  int main(void)
  {
    int trip_num, index, i;
    struct trip travel[MAXTRIP];
  
    printf("Enter number of trips: ");
    scanf("%d", &amp;trip_num);
    printf("Please enter destination letter/number of stops and cost/length of each stop:\n");
    for (index = 0; index &lt; trip_num; index++)
      {
        scanf("%c %d", &amp;travel[index].Dest_letter, &amp;travel[index].stop_num);
        for ( i=0; i &lt; travel[index].stop_num; i++)
      scanf("%f %f", &amp;travel[index].leg[i].cost, &amp;travel[index].leg[i].time);
      }
    for (index =0; index &lt; trip_num; index++)
      {
        printf("Trip:%d \nDestination Letter:%c", index+1, travel[index].Dest_letter);
        for (i=0; i &lt; travel[index].stop_num; i++)
      printf("Cost:%.2f \nLength:%.2f", travel[index].leg[i].cost, travel[index].leg[i].time);
      }
  }
  </code></pre>