Neuling braucht hilfe
-
Hallo liebes Forum,
ich bin relativ neu beim Programmieren, daher bitte ich um Verständnis, falls der Groschen nicht auf anhieb fällt.
Ich habe mir ein Buch zur C-Programmierung gekauft und bin fleißig am lesen und nachmachen, jedoch kommt bei einer Aufgabe folgender Fehler (ich programmiere über Eclipse für Mac):#include <stdio.h> #include <ctype.h> main() { char eingabe; int zahl; printf("\nWählen Sie (O)ktal, (H)ex oder (A)SCII > "); eingabe=getchar(); printf("\nBitte Dezimalzahl eingebn : "); scanf("%i",&zahl); switch(toupper(eingabe)); { case 'O': printf("Dezimal %i = Oktal %o \n",zahl,zahl); break; case 'H': printf("Dezimal %i = Hexadezimal %x \n",zahl,zahl); break; case 'A': if (zahl <= 255) printf("ACSII-Code %i entspricht %c \n",zahl,zahl); else printf("\nDiese Zahl ist zu groß! \n\a"); break; } }So Eclipse gibt mir jetzt folgenden Fehler aus:
../src/test.c:15: error: case label not within a switch statement
../src/test.c:17: error: break statement not within loop or switch
../src/test.c:18: error: case label not within a switch statement
../src/test.c:20: error: break statement not within loop or switch
../src/test.c:21: error: case label not within a switch statement
../src/test.c:26: error: break statement not within loop or switchIch bin hier schon am Ausrasten, also wäre nett wenn jemand helfen könnte.
-
Das Semikolon ist fehl am Platz:
switch(toupper(eingabe));
-
Zeile 12 Semikolon weg.
-
Danke, für die sehr schnelle Hilfe.