[C] Structure Input/Output

#include <stdio.h>

typedef struct Mt
{
    char mount[20];
    int alt;
}Mt;

int main(void)
{
    Mt m1 = { "Everest", 8848}, m2;
    printf(" Mt. want to go : ");
    scanf("%s", m2.mount);

    printf(" Mt. Height : ");
    scanf("%d", &m2.alt);

    printf(" Name : %s, Height : %dM \n", m1.mount, m1.alt);
    printf(" Name : %s, Height : %dM \n", m2.mount, m2.alt);

    return 0;

    /*
    Mt. want to go : Mt.Hanra
    Mt. Height : 1947
    Name : Everest, Height : 8848M
    Name : Mt.Hanra, Height : 1947M
    */
}

Reference

Tags:

Categories:

Updated: