C Program Passing Structure Element to a function

#include<stdio.h>
#include<conio.h>
void scan(char *,char *,int);
  struct stu
   {
    char name[20];
    char bran[20];
    int roll;
    };
    struct stu kb;
void main()
{
clrscr();
printf("Enter name:- ");
scanf("%s",&kb.name);

printf("Enter branch:- ");
scanf("%s",&kb.bran);

printf("Enter Roll No.:- ");
scanf("%d",&kb.roll);

scan(kb.name,kb.bran,kb.roll);
getch();
}

void scan(char *x,char *y,int z)
{
 printf("name= %s\nbranch= %s\nroll= %d",x,y,z);
}

OUTPUT:-

structure

Leave a Reply

Your email address will not be published. Required fields are marked *