javascript
Brief description  about Online courses   join in Online courses
View mahesh CV 's Profile

Can structures be passed to the functions by value?

Can structures be passed to the functions by value?
Asked by mahesh CV | Aug 5, 2010 |  Reply now
Replies (1)
View embedded instructor 's Profile
Yes, we can do it.
consider the following code..

#include<stdio.h>
#include<conio.h>
struct emp
{
int no;
int empno;
};
typedef struct emp empdata;

main()
{

empdata edata;
void display( empdata );

clrscr();
edata.no = 1;
edata.empno = 2005;
display( edata );

return 0;
}

void display( empdata pst )
{
printf( "%d", pst.empno );
}
Aug 5, 2010