pointer to structure and using structure in a function call

 #include <stdio.h>

#include<string.h>
struct employee
{
    int code;
    float salary;
    char name[10];

};
void show(struct employee emp)
{
printf("Code of employee1 is:%d\n",emp.code);
printf("Salary of employee1 is:%0.2f\n",emp.salary);
printf("Name of employee1 is:%s",emp.name);
}
int main(){

struct employee e1;
struct employee *ptr;
ptr=&e1;
//(*ptr).code=101;//can also be written as
ptr ->code=101;
(*ptr).salary=234.56;
strcpy(ptr->name,"Anchal");
show(e1);



return(0);
}

Comments