ASP ScriptingJava ScriptingCGI ScriptingHTMLJavaLanguage CERP Education Links

LANGUAGE C

Structure Pointers to Arguments

     Generally, structure pointers are used as arguments to functions rather than the structures themselves. This is done by declaring the formal argument of the function as a structure pointer. At the time of the function, a pointer to the structure or explicit address of a structure variable is passed to the functuion.This way it is the pointer that gets passed to the function at the time of invocation and not the structure itself.

     An advantage of this is that the elements of the structure can be modified in the function (call by reference).  

#include <stdio.h>
struct cust 
{
char name [ 20];
int numb;
int amt;
};
main ( )
{
struct cust *xyz;
printf("\nEnter Customer name : ") ;
gets(xyz->name); 
printf("\nEnter Customer Number :");
scanf("%d", &XyZ->numb); 
printf("\nEnter Principle Amount :");
scanf("%d", &xyz->amt);
}

 


Your Ad Here
Not All Of Your Subscribers Use RSS - AWeber Email Marketing
Your Ad Here