0
|
1 |
/*
|
|
2 |
* $Id: concatenation.c,v 1.1.1.1 2008-04-28 17:32:53 mbroeker Exp $
|
|
3 |
* $Source: /development/c/demos/concatenation.c,v $
|
|
4 |
*/
|
|
5 |
|
|
6 |
#include <stdio.h>
|
|
7 |
#include <stdlib.h>
|
|
8 |
#include <string.h>
|
|
9 |
|
|
10 |
struct P {
|
|
11 |
char *lastname;
|
|
12 |
char *firstname;
|
|
13 |
char *street;
|
|
14 |
int postal;
|
|
15 |
char *location;
|
|
16 |
};
|
|
17 |
|
|
18 |
typedef struct P Person;
|
|
19 |
|
|
20 |
#define insert(a) { person->a = a; }
|
|
21 |
#define show(a) { printf("%9s:\t%s\n", #a, person.a); }
|
|
22 |
#define show_int(a) { printf("%9s:\t%d\n", #a, person.a); }
|
|
23 |
|
|
24 |
void print_Person (Person person)
|
|
25 |
{
|
|
26 |
show (lastname);
|
|
27 |
show (firstname);
|
|
28 |
show (street);
|
|
29 |
show_int (postal);
|
|
30 |
show (location);
|
|
31 |
printf ("\n");
|
|
32 |
}
|
|
33 |
|
|
34 |
void set_Person (Person * person, char *lastname, char *firstname, char *street, int postal, char *location)
|
|
35 |
{
|
|
36 |
/*
|
|
37 |
* inserts <name> into person-><name>
|
|
38 |
*/
|
|
39 |
insert (lastname);
|
|
40 |
insert (firstname);
|
|
41 |
insert (street);
|
|
42 |
insert (postal);
|
|
43 |
insert (location);
|
|
44 |
}
|
|
45 |
|
|
46 |
int main (int argc, char **argv)
|
|
47 |
{
|
|
48 |
Person person[5];
|
|
49 |
int i;
|
|
50 |
|
|
51 |
set_Person (&person[0], "Breitkopf", "Manuela", "Maxim-Gorki-Strasse 49", 18106, "Rostock");
|
|
52 |
set_Person (&person[1], "Bröker", "Markus", "Maxim-Gorki-Strasse 25", 18106, "Rostock");
|
|
53 |
set_Person (&person[2], "Fischer", "Tina", "Ehm-Welk Straße 11", 18106, "Rostock");
|
|
54 |
set_Person (&person[3], "Jopp", "Marika", "Bleicherstraße 12", 18155, "Rostock");
|
|
55 |
set_Person (&person[4], "Rennert", "Nicole", "Willi-Bredel-Strasse 20", 18106, "Rostock");
|
|
56 |
|
|
57 |
for (i = 0; i < 5; i++) {
|
|
58 |
print_Person (person[i]);
|
|
59 |
}
|
|
60 |
|
|
61 |
return EXIT_SUCCESS;
|
|
62 |
}
|