All articles
c

A program to explain initialization of structures

Share this article

Share on LinkedIn Share on X (formerly Twitter)

C Programming Language 092

  • Write a program to explain initialization of structures

Program

#include <stdio.h>
 
struct bank
{
    char name[15];
    long int accno;
};
 
void main()
{
    struct bank b = {"John\0", 123456789012};
    printf("Name: %s\n", b.name);
    printf("Account no.: %ld\n", b.accno);
 
    printf("\n");
}

Result

Name: John
Account no.: 123456789012

Comments