title: Access violation in scanf_s
body: <p>I'm trying to make a program to just see what I can do with structures in C.  But getting an error in the main function at <code>scanf_s("%s", &amp;user.name)</code>:</p>
  
  <blockquote>
    <p>Exception thrown at 0x5C26D3EC (ucrtbased.dll) in StructureTest.exe:</p>
    
    <p>0xC0000005: Access violation writing location 0x01341000. occurred</p>
  </blockquote>
  
  <p>I also get some <a href="https://i.stack.imgur.com/ARsRB.png" rel="nofollow noreferrer">compiler warnings</a>.  This is my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  struct birthdate {
      int day;
      char month[9];
      int year;
  };
  
  typedef struct birthdate dob;
      struct info {
      char name[40];
      dob birthdate;
      int age;
      char sex[6];
      char *origin; 
  };
  void printinfo(struct info user) {
      printf("---- User Data ----\n");
      printf("Name: %s\n", user.name);
      printf("Date of birth: %d/%s/%d\n", user.birthdate.day, 
      user.birthdate.month, user.birthdate.year);
      printf("Age: %d\n", user.age);
      printf("Sex: %s\n", user.sex);
      printf("Country of origin: %s", user.origin);
  }
  
  int main() {
      printf("--Please enter your info--\n");
      struct info user;   
      printf("Please enter your name: ");
      scanf_s("%s", &amp;user.name); // &lt;-- exception thrown here
      printf("Please enter your date of birth in the format (dd/mm/yyyy): ");
      scanf_s("%d %s %d", &amp;user.birthdate.day, &amp;user.birthdate.month,
      &amp;user.birthdate.year);
      printf("Please enter your age: ");
      scanf_s("%d", &amp;user.age);
      printf("Please enter your gender ([M]ale/[F]emale): ");
      scanf_s("%s", &amp;user.sex);
      printf("Please enter your country of origin: ");
      scanf_s("%s", &amp;user.origin); // &lt;- Another exception thrown here
  
      printf("\n\n");
      printinfo(user);
  
      printf("\nPress ENTER to continue..");
      getchar();
      return 0;
  }
  </code></pre>
  
  <p>I'm not really experienced with structures yet, but I suspect it might have something to do with arrays and pointers, and the name I write in going into nowhere.</p>