Home

A program to explain POINTERS to STRUCTURE

C Programming Language 107

Program

#include <stdio.h>

struct bank
{
    char name[15];
    int accno;
};

void main()
{
    struct bank b, *p;
    p = &b;

    printf("Enter name and account no.: ");
    scanf("%s %d", p->name, &p->accno);

    printf("\nName = %s", p->name);
    printf("\nAcc no. = %d", p->accno);

    printf("\n");
}

Result

Enter name and account no.: John 123

Name = John
Acc no. = 123


Last Updated on

Next Post: Rules vs Guidelines →

Comments