home *** CD-ROM | disk | FTP | other *** search
- /* SOLAR.C - Beispiel aus Kapitel 4 der
- Einführung */
-
- #include <graphics.h>
- #include <stdio.h>
- #include <string.h>
-
- typedef struct {
- char name[10];
- float abstand;
- float radius;
- int farbe;
- int fill_typ;
- } planet;
-
- planet sonnen_system[9];
- planet *planet_ptr;
- int planet_num;
-
- int main()
- {
- strcpy(sonnen_system[0].name,"Merkur");
- sonnen_system[0].abstand = 0.4;
- sonnen_system[0].radius = 0.4;
- sonnen_system[0].farbe = EGA_YELLOW;
- sonnen_system[0].fill_typ = EMPTY_FILL;
-
- planet_ptr = sonnen_system;
-
- /* zeigt auf die zweite planet-Struktur */
- planet_ptr++;
-
- strcpy (planet_ptr->name,"Venus");
- planet_ptr->abstand = 0.7;
- planet_ptr->radius = 1.0;
- planet_ptr->farbe = EGA_BROWN;
- planet_ptr->fill_typ = SOLID_FILL;
-
- /* setzt den Zeiger auf das erste Element
- zurück */
- planet_ptr = sonnen_system;
-
- for (planet_num = 0;
- planet_num < 2;
- planet_num++, planet_ptr++)
- {
- printf("\nPlaneten-Statistik:\n");
- printf("Name: %s\n", planet_ptr->name);
- printf("Entfernung von der Sonne (in "
- "astronomischen Einheiten): %4.2f\n",
- planet_ptr->abstand);
- printf("Radius (in Erdradien): %4.2f\n",
- planet_ptr->radius);
- printf("Farbe: %d\n", planet_ptr->farbe);
- printf("Füllmuster: %d\n",
- planet_ptr->fill_typ);
- }
-
- return 0;
- }
-