concatenation.c
author Markus Bröker <mbroeker@largo.dyndns.tv>
Fri, 27 Dec 2013 16:00:09 +0100
changeset 167 7c6b221900bf
parent 77 49e0babccb23
permissions -rw-r--r--
Proper Datatypes to leave the 80's

/**
 * 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;
}