title: Struct with Char array is printing garbage... How to fix?
body: <p>I have the code below.  When I print out the data I assign to the character arrays in the struct it prints out a bunch of junk unless I add an extra character to the array and put "/0".  The problem with this is later on I need to grab the birth day and month as an integer (4 bytes).  Can anyone tell me how to make it print out the appropriate data?  I need the char array to be the exact size in memory of the size of the data.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  struct Info
  {
          char studentID[6];
          char firstName[5];
          char lastName[4];
          char birthDay[2];
          char birthMonth[2];
          char birthYear[4];
  };
  
  void printFunction( struct Info studentInfo );
  
  int main()
  {
          struct Info studentInfo = {"999999", "first", "last", "01", "07", "1993"};
          void *baseptr;
          asm("movl %%ebp,%0;":"=r"(baseptr));
          printf("The value of the basepointer main:\n");
          printf("%p\n", baseptr);
          printf("%-15s %s \n", "Student ID:", studentInfo.studentID);
          printf("%-15s %s \n", "First Name:", studentInfo.firstName);
          printf("%-15s %s \n", "Last Name:", studentInfo.lastName);
          printf("%-15s %s \n", "Birth Day:", studentInfo.birthDay);
          printf("%-15s %s \n", "Birth Month:", studentInfo.birthMonth);
          printf("%-15s %s \n", "Birth Year:", studentInfo.birthYear);
  
          printFunction( studentInfo );
          return 0;
  }
  
  void printFunction( struct Info studentInfo )
  {
          printf("The value of basepointer printFunction is:\n");
          int *baseptr;
          asm("movl %%ebp,%0;":"=r"(baseptr));
          printf("%p\n", baseptr);
          printf("The value at basepointer address is:\n");
          printf("%p\n", *baseptr);
          printf("%-25s %p \n", "Address of Student ID:", &amp;studentInfo.studentID);
          printf("%-25s %p \n", "Address of First Name:", &amp;studentInfo.firstName);
          printf("%-25s %p \n", "Address of Last Name:", &amp;studentInfo.lastName);
          printf("%-25s %p \n", "Address of Birth Day:", &amp;studentInfo.birthDay);
          printf("%-25s %p \n", "Address of Birth Month:", &amp;studentInfo.birthMonth);
          printf("%-25s %p \n", "Address of Birth Year:", &amp;studentInfo.birthYear);
          printf("%s %x \n", "The address of my birth day and month is at address: ", &amp;studentInfo.birthDay );
          printf("%s \n", "The integer value of my birth day and month is: ");
  }
  </code></pre>