concatenation.c
author Markus Bröker <mbroeker@largo.dyndns.tv>
Fri, 19 Nov 2010 14:49:47 +0100
changeset 159 44823a881da1
parent 77 49e0babccb23
permissions -rw-r--r--
set default socket options: IPV6_V6ONLY, SO_REUSEADDR committer: Markus Bröker <mbroeker@largo.homelinux.org>

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