Einzelnen Beitrag anzeigen
Ungelesen 13.12.12, 21:04   #20
Metal_Rex
Anfänger
 
Registriert seit: Dec 2011
Beiträge: 17
Bedankt: 0
Metal_Rex ist noch neu hier! | 0 Respekt Punkte
Standard

Also das mit -std=c99 scheint nur zu funktionieren wenn ich es im Projekt unter den Optionen festlege. Wenn ich es aber so in den Text reinschreibe funktioniert es nicht. Also ich werd aus den Dingern nicht schlau xD

Nungut, es lag an den () für int nun aber wieder weitere Fehler :

In function 'main':
32 error: expected ';' before '}' token
=== Build finished: 1 errors, 0 warnings ===

aber da ist doch alles richtig O.o



PHP-Code:
// Getränkeautomat

#include <stdio.h>
#include <stdlib.h>

int main() {

    
//Getränkeliste
    
printf("\n        Our drinks:");
    
printf("\n--------------------------");
    
printf("\n1) Coca Cola         1.85$");
    
printf("\n2) Ice Tea           1.45$");
    
printf("\n3) Water             1.20$");

    
//Getränkeauswahl
    
int choice;
    
double costspayedpayed2;
    
double dollars[12] = {0.010.050.100.250.501,        //Münzen
                          
25102050100} ;                //Scheine, keine 1$ Note

    
printf("\n\n\nPlease choose your drink: ");
    
scanf("%d", &choice);

    switch (
choice) {
        case 
1:
            
costs 1.85;
            
printf("\nYou choose Coca Cola. Please insert 1.85$: ");
            break;

        case 
2:
            
costs 1.45;
LINE 32             printf("\nYou choose Ice Tea. Please insert 1.45$: ");
            break;

        case 
3:
            
costs 1.20;
            
printf("\nYou choose Water. Please insert 1.20$: ");
            break;

        default:
            
printf("\nYou choose nothing. See you!");
            exit(
0);
    }

    
scanf("%lf", &payed);

    while (
payed costs) {
        
printf("Please insert more money (%2.2lf$ left): "costs payed);
        
scanf("%lf", &payed2);
        
payed += payed2;
    }

    
printf("\nYou insert: %2.2lf\nYour change: %.2lf\n"payedpayed costs);

    if (
payed costs) {
        
printf("Take: \n");
        
payed -= costs;        //in payed steht ab jetzt nur noch das verbleibende Wechselgeld

        
for (int i 11>= 0i--) {
            if (
payed >= dollars[i]) {
                
printf("%d x %10.02lf$\n", (int)(payed dollars[i]), dollars[i]);
                
payed -= (int)(payed dollars[i]) * dollars[i];
            }
        }
    }

    return 
0;

Metal_Rex ist offline   Mit Zitat antworten