concatenation.c
author Markus Bröker <mbroeker@largo.dyndns.tv>
Thu, 16 Apr 2009 12:50:39 +0200
changeset 70 ded389a5dc2a
parent 27 81a574d60c15
child 77 49e0babccb23
permissions -rw-r--r--
Profiling support added * To use the benefits of profiling, set PROFILING=<target> * eg: mbroeker@localhost $ make -e PROFILING=linux * mbroeker@localhost $ export PROFILING=linux && make committer: Markus Bröker <mbroeker@largo.homelinux.org>

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