T
Thomas_xp
Aktives Mitglied
Thread Starter
- Dabei seit
- 05.04.2006
- Beiträge
- 632
- Reaktionspunkte
- 13
Weiß einer hier wie ich folgende Datei compiliere??? Problem schein die graphics.h zu sein. Wie binde ich die beim Compilieren ein???
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <graphics.h>
/*---------- Makros fuer die Symbole der Produktionsregeln ---------------*/
#define F f(t-1); /* F */
#define M phi=phi-delta; /* - */
#define P phi=phi+delta; /* + */
#define A_ altx=x; alty=y; altphi=phi; /* [ */
#define _Z x=altx,y=alty,moveto((int)x,(int)y); phi=altphi; /* ] */
double x, y, laenge, phi, delta; /* Globale Variablen */
void f(int t);
/*---------- main -------------------------------------------------------*/
int main( int argc, char *argv[] )
{
const double PI=4*atan(1);
int t, maxX=480, maxY=480;
int anfWinkel = 90; /* Winkel zum Zeichnen der ersten Gerade */
double drehWinkel = 22.5; /* Drehwinkel */
double faktor = 0.5; /* Verkleinerungsfaktor fuer Laenge bei Rekursion */
int rekTiefe = 7; /* Rekursionstiefe */
delta = (drehWinkel*PI)/180; /*---- Umrechnen Winkel in Bogenmass */
laenge = maxY/4;
initgraph(maxX, maxY);
for (t=1; t <= rekTiefe; t++) {
cleardevice(WHITE);
phi = (anfWinkel*PI)/180; /*---- Umrechnen Winkel in Bogenmass */
x = maxX/2;
y = maxY;
moveto( (int)x, (int)y );
f(t);
laenge *= faktor;
getch();
}
closegraph();
return 0;
}
/*---------- f ----------------------------------------------------------*/
void f(int t) {
double altx, alty, altphi;
if (t > 1) {
F F M A_ M F P F P F _Z P A_ P F M F M F _Z
} else {
x += laenge*cos(-phi);
y += laenge*sin(-phi);
lineto( (int)x, (int)y );
}
}
Im Terminal wird folgende Meldung gepostet:
MacBook:~/programming Name$ gcc pflanze1.c -ls -lm -lg
pflanze1.c:4:23: error: graphics.h: No such file or directory
pflanze1.c: In function 'main':
pflanze1.c:30: error: 'WHITE' undeclared (first use in this function)
pflanze1.c:30: error: (Each undeclared identifier is reported only once
pflanze1.c:30: error: for each function it appears in.)
Kristina-MacBook:~/programming Kika$
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <graphics.h>
/*---------- Makros fuer die Symbole der Produktionsregeln ---------------*/
#define F f(t-1); /* F */
#define M phi=phi-delta; /* - */
#define P phi=phi+delta; /* + */
#define A_ altx=x; alty=y; altphi=phi; /* [ */
#define _Z x=altx,y=alty,moveto((int)x,(int)y); phi=altphi; /* ] */
double x, y, laenge, phi, delta; /* Globale Variablen */
void f(int t);
/*---------- main -------------------------------------------------------*/
int main( int argc, char *argv[] )
{
const double PI=4*atan(1);
int t, maxX=480, maxY=480;
int anfWinkel = 90; /* Winkel zum Zeichnen der ersten Gerade */
double drehWinkel = 22.5; /* Drehwinkel */
double faktor = 0.5; /* Verkleinerungsfaktor fuer Laenge bei Rekursion */
int rekTiefe = 7; /* Rekursionstiefe */
delta = (drehWinkel*PI)/180; /*---- Umrechnen Winkel in Bogenmass */
laenge = maxY/4;
initgraph(maxX, maxY);
for (t=1; t <= rekTiefe; t++) {
cleardevice(WHITE);
phi = (anfWinkel*PI)/180; /*---- Umrechnen Winkel in Bogenmass */
x = maxX/2;
y = maxY;
moveto( (int)x, (int)y );
f(t);
laenge *= faktor;
getch();
}
closegraph();
return 0;
}
/*---------- f ----------------------------------------------------------*/
void f(int t) {
double altx, alty, altphi;
if (t > 1) {
F F M A_ M F P F P F _Z P A_ P F M F M F _Z
} else {
x += laenge*cos(-phi);
y += laenge*sin(-phi);
lineto( (int)x, (int)y );
}
}
Im Terminal wird folgende Meldung gepostet:
MacBook:~/programming Name$ gcc pflanze1.c -ls -lm -lg
pflanze1.c:4:23: error: graphics.h: No such file or directory
pflanze1.c: In function 'main':
pflanze1.c:30: error: 'WHITE' undeclared (first use in this function)
pflanze1.c:30: error: (Each undeclared identifier is reported only once
pflanze1.c:30: error: for each function it appears in.)
Kristina-MacBook:~/programming Kika$