V
vadud3
Hi All
I am trying to compile the following program:
#include <stdio.h>
#include <string.h>
typedef struct employee {
int id;
char name[10];
float salary;
} e;
void processEmp(e); //supply function prototype with structure alias
name
main()
{
e empl = {0,'\0',0}; //Initialize members
processEmp (empl); //pass structure by value
printf("\nID: %d\n", empl.id);
printf("Name: %s\n", empl.name);
printf("Salary : $%.2f\n", empl.salary);
} // end main
void processEmp(e emp) //receives a copy of the structure
{
emp.id = 123;
strcpy(emp.name, "Sheila");
emp.salary = 65000.00;
} //end processEmp
I compile it using gcc 3.3.2 on Mandrake 10.2 like this
gcc program.c
But when I run ./a.out it shows
ID: 0
Name:
Salary : $0.00
I was expecting the output be like this:
ID: 123
Name: Sheila
Salary : $65000.00
Any thing I am doing wrong?
Thanks for the help
I am trying to compile the following program:
#include <stdio.h>
#include <string.h>
typedef struct employee {
int id;
char name[10];
float salary;
} e;
void processEmp(e); //supply function prototype with structure alias
name
main()
{
e empl = {0,'\0',0}; //Initialize members
processEmp (empl); //pass structure by value
printf("\nID: %d\n", empl.id);
printf("Name: %s\n", empl.name);
printf("Salary : $%.2f\n", empl.salary);
} // end main
void processEmp(e emp) //receives a copy of the structure
{
emp.id = 123;
strcpy(emp.name, "Sheila");
emp.salary = 65000.00;
} //end processEmp
I compile it using gcc 3.3.2 on Mandrake 10.2 like this
gcc program.c
But when I run ./a.out it shows
ID: 0
Name:
Salary : $0.00
I was expecting the output be like this:
ID: 123
Name: Sheila
Salary : $65000.00
Any thing I am doing wrong?
Thanks for the help