title: Error in passing Struct as argument to a function by value in gcc ver 4.6.3
body: <p>I am a newbie to C Programming and I am learning to pass a struct as a parameter to a function (as part of my course) by value. I am using gcc ver 4.6.3 on Ubuntu Linux 12.04LTS
  The following is the source code which seems logically and syntactically correct (to me) but I get errors when compiling it:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  struct sal {
      char name[30];
      int no_of_days_worked;
      int daily_wage;
  };
  typedef struct sal Sal;
  
  void main()
  {
      Sal salary;
      int amount_payable;
      salary=get_data(salary);           //Passing struct as function arguments
      printf("\nThe name of the Employee is %s",salary.name);
      printf("\nNumber of days worked is %d",salary.no_of_days_worked);
      printf("\nThe daily wage of the employees is %d",salary.daily_wage);
      amount_payable=wages(salary);
      printf("\nThe amount payable to %s is %d",salary.name,amount_payable);
  }
  
  Sal get_data(Sal income)
  {
      printf("\nEnter the name of the Employee: \n");
      scanf("%s",&amp;income.name);
      printf("\nEnter the number of days worked:\n");
      scanf("%d",&amp;income.no_of_days_worked);
      printf("\nEnter the employee daily wages:\n");
      scanf("%d",&amp;income.daily_wage);
      return(income);                                //Return back a struct data type
  }
  
  int wages(Sal x)
  {
      int total_salary;
      total_salary=x.no_of_days_worked*x.daily_wage;
      return(total_salary);
  } 
  </code></pre>
  
  <p>On compiling the code I get the following errors:</p>
  
  <pre><code>struct_to_function.c: In function ‘main’:
  struct_to_function.c:15:7: error: incompatible types when assigning to type ‘Sal’ from type ‘int’
  struct_to_function.c: At top level:
  struct_to_function.c:22:5: error: conflicting types for ‘get_data’
  struct_to_function.c:15:8: note: previous implicit declaration of ‘get_data’ was here
  struct_to_function.c: In function ‘get_data’:
  struct_to_function.c:25:1: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[30]’ [-Wformat]
  </code></pre>
  
  <p>I think it has some thing to do with the implementation or execution plan of the gcc compiler whether the compiler is using a stack or registers. Again these are just my amateurish assumptions.</p>