Create a structure that has array members - C Structure

C examples for Structure:Structure Definition

Description

Create a structure that has array members

Demo Code

#include <stdio.h>

struct data{//  w  ww . j  av  a2s . c  o  m
    float amount;
    char fname[30];
    char lname[30];
} rec;

int main( void )
{
    printf("Enter the first and last names,\n");
    printf("separated by a space: ");
    scanf("%s %s", rec.fname, rec.lname);

    printf("\nEnter the amount: ");
    scanf("%f", &rec.amount);

    printf("\nDonor %s %s gave $%.2f.\n", rec.fname, rec.lname, rec.amount);

    return 0;
}

Result


Related Tutorials