Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Pass Structure as a function Argument in C

    • 0
    • 2
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 475
    Comment on it

    To Pass the Structure as a function Argument we just need to Create the Object of the Structure and pass it as a argument to the funtion .

     #include<stdio.h>
            #include<conio.h>
    
    
     struct anp//Name of the structure
        {
        int rlno;  //Structre elements
      char name[15];
        }p;//structure variable
       void print(struct anp *);
    
            void main()
            {
            clrscr();
            printf("Enter the rlno and name\n");
            scanf("%d%s",&p.rlno,p.name);
            print(&p);//calling the function print and &p is strcuture Argument
            getch();
            }
            void print(struct anp *q)
            {
            printf("Entered ROLLNO =%d Entered Name= %s",q->rlno,q->name);
            }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: