Δημοσιεύτηκε: 24 Ιουν 2011, 02:48
από clepto
έχω άλλο πρόβλημα τώρα...
άρχισα να φτιάχνω ένα πρόγραμμα με τύπους της φυσικής της 1ης λυκείου για υπολογισμούς (Qdata σου κλέβω την ιδέα :mrgreen: :P :oops: )
ο κώδικας είναι αυτός:

Κώδικας: Επιλογή όλων
#include<stdio.h>
#include<math.h>
#include<stdlib.h>



kinhseis() {

char kin;

printf("Αν το κινητό εκτελεί Ευθύγραμμη Ομαλή Κίνηση (Ε.Ο.Κ.) πατήστε ένα (1)/n Αν εκτελεί Ευθύγραμμη Ομαλά Επιταχυνόμενη πατήστε δύο (2)/n Αν εκτελεί Ευθύγραμμη Ομαλά Επιβραδυνόμενη πατήστε τρία (3)/n");
scanf("%c", &kin);

switch(kin)
{
case "1":
eok();
break;

case "2":
eoept();
break;

case "3":
eoepv();
break;
}
}

eok() {

int u1, x1, t1;
char ceok;

printf("Για να βρείτε την ταχύτητα του κινητού πατήστε ένα (1)/n Για να βρείτε το διάστημα που διένυσε δύο (2)/n Τον χρόνο που έκανε τρίτα (3)/n");
scanf("%c", ceok);

switch(ceok)
{
case "1":
printf("Γράψτε το διάστημα και την χρονική στιγμή: ");
scanf("%d %d", &x1, &t1);
u1 = (x1/t1);
printf("Η ταχύτητα του κινητού την χρονική στιμή %d s είναι %d m/s", t1, u1);
break;

case "2":
printf("Γράψτε την ταχύτητα και την χρονική στιγμή: ");
scanf("%d %d", &u1, &t1);
x1 = (u1*t1);
printf("Το κινητό την χρονική στιμή %d s έχει διανύσει %d m", t1, x1);
break;

case "3":
printf("Γράψτε την ταχύτητα και το διάστημα: ");
scanf("%d %d", &u1, &x1);
t1 = (x1/u1);
printf("Η χρονική στιμή που ψάχνετε είναι %d s", t1);
break;
}
}


λείπουν πολλά πράγματα ακόμα αλλά πήγα να κάνω compile για να δω αν τρέχει μέχρι εδώ και χτύπησε κόκκινο :P

Κώδικας: Επιλογή όλων

gcc -Wall -o "physic" "physic.c" (στο φάκελο: /home/chris/C)
physic.c:32:2: warning: return type defaults to ‘int’
physic.c: In function ‘kinhseis’:
physic.c:41:4: error: case label does not reduce to an integer constant
physic.c:42:5: warning: implicit declaration of function ‘eok’
physic.c:45:4: error: case label does not reduce to an integer constant
physic.c:46:5: warning: implicit declaration of function ‘eoept’
physic.c:49:4: error: case label does not reduce to an integer constant
physic.c:50:5: warning: implicit declaration of function ‘eoepv’
physic.c: At top level:
physic.c:55:2: warning: return type defaults to ‘int’
physic.c: In function ‘eok’:
physic.c:61:3: warning: format ‘%c’ expects type ‘char *’, but argument 2 has type ‘int’
physic.c:65:4: error: case label does not reduce to an integer constant
physic.c:72:4: error: case label does not reduce to an integer constant
physic.c:79:4: error: case label does not reduce to an integer constant
Αποτυχία μεταγλώτισης.
physic.c:86:4: warning: control reaches end of non-void function
physic.c: In function ‘kinhseis’:
physic.c:53:5: warning: control reaches end of non-void function