title: Implementing simple Login function in C
body: <p>I am trying this login program in C but due to some reasons the program gets stuck in infinity loop the moment user name is entered.I have double checked my code but could not find anything wrong in it.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  #include&lt;string.h&gt;
  
  char *name="bob";       //test data
  char *password="pas";
  
  int user_name()
  {
  fflush(stdin);
  char *c[10],*p[10];
  printf("user name enter\n");
  
  if(fgets(c,10,stdin))     //check if any user data entered
  {
      if(name==NULL)
    {
      printf("welcome user created\n");
      strcpy(name,c);
      fflush(stdin);
      printf("create a password\n");
      fgets(password,10,stdin);
      return 1;
    }
   else
   {
      if(strcmp(name,c)==0)         //if user input matched existing username
      {
          fflush(stdin);
          printf("enter password");
          fgets(p,10,stdin);       //take in password
          if(strcmp(p,password)==0) //compare password
          return 1;
  
  
      }
  
       return 0;
    }
  
  }
  
  int main()
  {
   int t=0;
   t=user_name();
   if(t==1)
  
      printf("welcome");
   else
      printf("sorry");
      return 1;
  </code></pre>
  
  <p>}</p>
  
  <p>Please help me in finding the problem.</p>