concatenation.c
author Markus Bröker<broeker.markus@googlemail.com>
Sun, 10 Feb 2019 13:17:01 +0100
changeset 173 374a86886bc5
parent 77 49e0babccb23
permissions -rw-r--r--
LAST-DIGIT-BUG: INCREMENT before LF

/**
 * concatenation.c
 * Copyright (C) 2008 Markus Broeker
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct P {
    char *lastname;
    char *firstname;
    char *street;
    int postal;
    char *location;
};

typedef struct P Person;

#define insert(a) { person->a = a; }
#define show(a) { printf("%9s:\t%s\n", #a, person.a); }
#define show_int(a) { printf("%9s:\t%d\n", #a, person.a); }

void print_Person (Person person)
{
    show (lastname);
    show (firstname);
    show (street);
    show_int (postal);
    show (location);
    printf ("\n");
}

void set_Person (Person * person, char *lastname, char *firstname, char *street, int postal, char *location)
{
    /*
     * inserts <name> into person-><name>
     */
    insert (lastname);
    insert (firstname);
    insert (street);
    insert (postal);
    insert (location);
}

int main (int argc, char **argv)
{
    Person person[5];

    int i;

    set_Person (&person[0], "Breitkopf", "Manuela", "Maxim-Gorki-Strasse 49", 18106, "Rostock");
    set_Person (&person[1], "Bröker", "Markus", "Maxim-Gorki-Strasse 25", 18106, "Rostock");
    set_Person (&person[2], "Fischer", "Tina", "Ehm-Welk Straße 11", 18106, "Rostock");
    set_Person (&person[3], "Jopp", "Marika", "Bleicherstraße 12", 18155, "Rostock");
    set_Person (&person[4], "Rennert", "Nicole", "Willi-Bredel-Strasse 20", 18106, "Rostock");

    for (i = 0; i < 5; i++) {
        print_Person (person[i]);
    }

    return EXIT_SUCCESS;
}