title: Cannot print a function's return value in another function in C
body: <p>I have a function named Login() that reads a username(ex. <code>"John"</code>) and then create a password that is the username itself with each letter upper or lower in random (ex. <code>"JoHn"</code>)inside a new function called <code>password()</code> .However when I try to print the password in Login() as a return statement from <code>password()</code> it prints null;</p>
  
  <p>This is the function that returns the password : </p>
  
  <pre><code>void Login()  
  {  
      char passwd[20];
      char name[20];
  
      printf(" Please enter your username : \n");
      do
      {
          scanf(" %s",&amp;name);
      }while(strcmp(name,"John")!=0);
  
  
  
      printf("Your password is : %s\n",password(name));
  
      printf("Please enter your password : \n");
  
      do
      {
          scanf(" %s",&amp;passwd);
      }while(strcmp(passwd,password(name))!=0);
  
  }
  </code></pre>
  
  <p>And this is the function that returns the password : </p>
  
  <pre><code>char password( char pass[])
  {
  
      int i;
      int k;
  
      for(i=0;i&lt;strlen(pass);i++)
      {
          k= rand()%2;
          if(k==1)
          {
              pass[i]=toupper(pass[i]);
          }
          else{
              pass[i]=tolower(pass[i]);
          }   
      }
  
      return pass;
  }
  </code></pre>
  
  <p>Now when I run <code>Login()</code> in <code>main</code> i get </p>
  
  <blockquote>
    <p>"Your password is : (null)"  </p>
  </blockquote>
  
  <p>How can I fix this problem ?</p>