C examples for Structure:Structure Value
Passing Structures by Reference
#include <stdio.h> #include <string.h> typedef struct employee { int id; /*from w w w . ja v a 2 s. c o m*/ char name[10]; float salary; } emp; void processEmp(emp *); int main() { emp emp1 = {0, 0, 0}; emp *ptrEmp; ptrEmp = &emp1; processEmp(ptrEmp); printf("\nID: %d\n", ptrEmp->id); printf("Name: %s\n", ptrEmp->name); printf("Salary: $%.2f\n", ptrEmp->salary); } void processEmp(emp *e) { e->id = 123; strcpy(e->name, "Mary"); e->salary = 65000.00; }