concatenation.c
author Markus Bröker <mbroeker@largo.dyndns.tv>
Sat, 13 Dec 2008 12:58:26 +0100
changeset 0 af501b0c1716
child 9 c3fecc82ade6
permissions -rw-r--r--
demos cvs copy committer: Markus Bröker <mbroeker@largo.homelinux.org>

/*
 *     $Id: concatenation.c,v 1.1.1.1 2008-04-28 17:32:53 mbroeker Exp $
 * $Source: /development/c/demos/concatenation.c,v $
 */

#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;
}