Please answer in low level English. I have a question about a piece of code, which doesn't work and I don't know why. I want to give out a field of 5x5 Points (.), it works. Then I want to save a name on a coordinate (for example 3,4) and the compiler doesn't recognizes a fault, but Visual Studio always ends the program after cout << "Name: "; and doesn't notice the command cin.get(Feld[xWert][yWert].Feldname, 19); and also doesn't notice the condition of the do-while loop. I don't know why. You can copy the piece of code 1:1 in your compiler. It would please me, if you can help me. I translated the few German words into English here:
(Feld=field ; Felddaten =data_of_the_field ; Feldbesetzt = occupied_field ; Feldname = name_of_the_field; Auswahl=choice ; Hoehe =height ; Breite= width; Wert=value)
#include <iostream>
using namespace std;
int main() {
struct Felddaten {
bool Feldbesetzt;
char Feldname[20];
};
Felddaten Feld[5][5];
int Auswahl;
int Hoehe = 5;
int Breite = 5;
for (int x = 0; x < Hoehe; x++) {
for (int y = 0; y < Hoehe; y++) {
Feld[x][y].Feldbesetzt = false;
}
}
for (int x = 0; x < Hoehe; x++) {
for (int y = 0; y < Hoehe; y++) {
if (Feld[x][y].Feldbesetzt == false)
cout << ".";
}
cout << endl;
}
int xWert;
int yWert;
do {
cout << "XPosition";
cin >> xWert;
cout << "YPosition";
cin >> yWert;
cout << "Name: ";
cin.get(Feld[xWert][yWert].Feldname, 19);
} while ((xWert > 4) && (yWert > 4) && (xWert < 0) && (yWert < 0));
return 0;
}