Schleife in Funktion funktioniert nicht
-
Warum funktioniert in dem Code die Schleife nicht?? Also eigentlich müsste doch 30 mal ein "*" da stehen oder nichT? Bei mir steht es nur einmal da!???
void Trennzeile(); int main() { int i; cout << "Hallo!"<<endl; Trennzeile(); cout << "Nochmal!!"<<endl; Trennzeile(); cout << "Jetzt ist aber Schluss!" <<endl; cin >> i; return 0; } void Trennzeile() { int x; for (x=0; x<30; x++);{ cout << "*"; cout <<endl; } }
-
; wegnehmen in der zeile mit der for-schleife
-
mach mal das semikolon nach for(...) weg ...
-
Ah okay, danke. Hätte ich ja eigentlich auch selber drauf kommen können, na ja egal. Also danke für die Antworten!!!!!!!!
-
Irgendwie habe ich das Gefühl, das ich das ganze Thema nicht wirklich kapiere, warum funktioniertd er Code denn schon wieder nicht????
void Trennzeile(char , int); int main() { int i; cout << "Hallo!"<<endl; Trennzeile( "-" , 30); cout << "Nochmal!!"<<endl; Trennzeile("+",10); cout << "Jetzt ist aber Schluss!" <<endl; cin >> i; return 0; } void Trennzeile(char cZeichen, int iAnzahl) { int x; for (x=0; x<iAnzahl; x++) { cout << cZeichen; } cout <<endl; }
-
Trennzeile( '-' , 30); // !!!!!!!!!!!!!!!
Trennzeile( '+' , 30); // !!!!!!!!!!!!!!!
-
Ja, dat is wohl richtig! Na gut, dann nochmals danke!!!!!!!