C program to pass a structure to a user define function
Given a structure and we have to pass it to a function in C.
structure declaration is:
- exam is the structure name
- marks and name are the members of the structure/variable of the structure
Here is the function that we are using in the program,
void structfun(struct exam obj1);
- void is the returns type of the function i.e. function will not return any value.
- structfun is the name of the function.
- struct exam obj1 is the object of exam structure - while declaring a function we must have to use struct keyword with the structure name.
Structure object/variable declaration is:
struct exam obj;
Assigning values to the structure variable inside the main
obj.marks = 50;
strcpy(obj.name , "Arjun kapoor");
Function calling statement,