I dont understand the datatype char very well. Its because of that example:
char test;
cin >> test;
cout << test;
If i input now more than one char, the program only prints the first letter.
char test = (char)"Hello";
But If I cast a string like hello to a char, the program doesnt take the first letter.
void menu() {
char mode = ' ';
cout << "Gebe einen Modus an. 1 Addition, 2 Subtraktion, 3 Multiplikation, 4 Division: ";
cin >> mode;
switch (mode) {
case '1':
addition();
break;
case '2':
subtraktion();
break;
case '3':
multiplikation();
break;
case '4':
division();
break;
default:
cout << "Ungueltige Eingabe, versuch es nochmal\n";
menu();
break;
}
}
Also in this example, If I give the program as an input more than one letter, the default condition will be executed so many times, as the length of the input.
I dont understand those three examples well, could anybody explain me everything in easy from the start=? That would be really nice! Thanks in advance