How to Pass structure pointer to function in C

#include <stdio.h>
struct MyStruct
{
    char a;
    int i;
};

void print_structure(struct MyStruct *sptr){
    printf("Value of a is = %c\n",sptr->a);
    printf("Value of i is = %d\n",sptr->i);
}


int main()
{
    struct MyStruct m = {'d',40};
    print_structure(&m);
    

return 0;
}

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

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