title: variable has incomplete type 'struct login l;' in C
body: <p>I have a school project to create a program in C, in which users can login through their credentials and vote on a single issue using yes or no.</p>
  <p>I got this code for the login system, but is giving an error about incomplete variable type.</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  int main(void){
  
  struct login                           // before the first use of `l`.
  {
  char fname[30];
  char lname[30];
  char username[30];
  char password[20];
  };
  
  void login (void);
  void registration (void);
  
  
  int option;
  
  printf(&quot;Press '1' to Register\nPress '2' to Login\n\n&quot;);
  scanf(&quot;%d&quot;,&amp;option);
  
  getchar();           // catching newline.
  
  if(option == 1)
      {
          system(&quot;CLS&quot;);
          registration();
      }
  
  else if(option == 2)
      {
          system(&quot;CLS&quot;);
          login();
      }
      }
  
      void login (void)
      {
      char username[30],password[20];
      FILE *log;
  
      log = fopen(&quot;login.txt&quot;,&quot;r&quot;);
      if (log == NULL)
      {
      fputs(&quot;Error at opening File!&quot;, stderr);
      exit(1);
      }
  
      struct login l;
  
      printf(&quot;\nPlease Enter your login credentials below\n\n&quot;);
      printf(&quot;Username:  &quot;);
      fgets(username, 30, stdin);
      printf(&quot;\nPassword: &quot;);
      printf(&quot;\n&quot;);
      fgets(password, 20, stdin);
  
      while(fread(&amp;l,sizeof(l),1,log))
      {
      if(strcmp(username,l.username)==0 &amp;&amp; strcmp(password,l.password)==0)
  
          {   
              printf(&quot;\nSuccessful Login\n&quot;);
          }
      else 
          {
              printf(&quot;\nIncorrect Login Details\nPlease enter the correct credentials\n&quot;);
          }
      }
  
  fclose(log);
  
  return;
  }
  
  
  
  
  void registration(void)
  { 
  char firstname[15];
  FILE *log;
  
  log=fopen(&quot;login.txt&quot;,&quot;w&quot;);
  if (log == NULL)
  {
      fputs(&quot;Error at opening File!&quot;, stderr);
      exit(1);
  }
  
  
  struct login l;
  
  printf(&quot;\nWelcome to your online course provider. We need to enter some details for registration.\n\n&quot;);
  printf(&quot;\nEnter First Name:\n&quot;);
  scanf(&quot;%c&quot;,l.fname);
  printf(&quot;\nEnter Surname:\n&quot;);
  scanf(&quot;%s&quot;,l.lname);
  
  printf(&quot;Thank you.\nNow please choose a username and password as credentials for system login.\nEnsure the username is no more than 30 characters long.\nEnsure your password is at least 8 characters long and contains lowercase, uppercase, numerical and special character values.\n&quot;); 
  }
  </code></pre>
  <p>This is the error I'm getting at line 50 and 93</p>
  <pre><code>Main.c:50:18: error: variable has incomplete type 'struct login'
  struct login l;
               ^
  Main.c:50:12: note: forward declaration of 'struct login'
  struct login l;
         ^
  Main.c:93:18: error: variable has incomplete type 'struct login'
  struct login l;
               ^
  `Main.c:93:12: note: forward declaration of 'struct login'
  struct login l;
  </code></pre>
  <p>Can someone please help me with the error?</p>