Quellcode
- #include <iostream>
- using namespace std;
- struct S_FeldInfo
- {
- bool Besetzt;
- char Name[30];
- };
- const int Breite = 5;
- const int Hoehe = 5;
- S_FeldInfo Spielfeld[Breite][Hoehe];
- void LoescheSpielfeld ();
- void ZeigeSpielfeld ();
- void ZeigeFelddaten ();
- void BesetzeFeld ();
- int main ()
- {
- int Auswahl = 0;
- LoescheSpielfeld ();
- do
- {
- cout << endl;
- cout << "1 - Spielfeld anzeigen" << endl;
- cout << "2 - Feld besetzen" << endl;
- cout << "3 - Felddaten anzeigen" << endl;
- cout << "4 - Spielfeld loeschen" << endl;
- cout << "5 - Programm beenden" << endl;
- cout << "Auswahl: ";
- cin >> Auswahl;
- switch (Auswahl)
- {
- case (1):
- {
- ZeigeSpielfeld ();
- } break;
- case (2):
- {
- BesetzeFeld ();
- } break;
- case (3):
- {
- ZeigeFelddaten ();
- } break;
- case (4):
- {
- LoescheSpielfeld ();
- cout << "Spielfeld wurde geloescht!" << endl;
- } break;
- case (5):
- {
- cout << "Programm beendet." << endl;
- } break;
- default:
- {
- cout << "Ungueltiger Menuepunkt!" << endl;
- }
- }
- } while (Auswahl != 5);
- return 0;
- }
- void LoescheSpielfeld ()
- {
- for (int y=0; y<Hoehe; y++)
- {
- for (int x=0; x<Breite; x++)
- {
- Spielfeld[x][y].Besetzt = false;
- }
- }
- }
- void ZeigeSpielfeld ()
- {
- cout << endl;
- for (int y=0; y<Hoehe; y++)
- {
- for (int x=0; x<Breite; x++)
- {
- if (Spielfeld[x][y].Besetzt == true)
- cout << "X";
- else
- cout << ".";
- }
- cout << endl;
- }
- }
- void BesetzeFeld ()
- {
- int x = 0;
- int y = 0;
- do
- {
- cout << "x-Position (1-" << Breite << "): ";
- cin >> x;
- } while (x<1 || x>Breite);
- do
- {
- cout << "y-Position (1-" << Hoehe << "): ";
- cin >> y;
- } while (y<1 || y>Breite);
- cout << "Name: ";
- cin.ignore ();
- cin.get (Spielfeld[x-1][y-1].Name, 29);
- Spielfeld[x-1][y-1].Besetzt = true;
- }
- void ZeigeFelddaten ()
- {
- int x = 0;
- int y = 0;
- do
- {
- cout << "x-Position (1-" << Breite << "): ";
- cin >> x;
- } while (x<1 || x>Breite);
- do
- {
- cout << "y-Position (1-" << Hoehe << "): ";
- cin >> y;
- } while (y<1 || y>Breite);
- if (Spielfeld[x-1][y-1].Besetzt == false)
- {
- cout << "Dieses Feld ist noch nicht besetzt." << endl;
- }
- else
- {
- cout << "Feld ist besetzt von: ";
- cout << Spielfeld[x-1][y-1].Name << endl;
- }
- }
Was das Programm machen soll, erkennt man ja schnell.Der Code ist an Sich doch eigentlich auch richtig, aber trotzdem haut mir MCV C++ 2010 Express einen Fehler hinaus.Er zeigt nicht mal an was es ist, ob es ein Syntax Fehler ist oder ob man irgendetwas nicht laden konnte oder sonst was.Nein da steht nur Fehler. Der ist so gravierend das er den Build nicht ausführt.Ich muss euch mal wieder fragen.Danke!