Hallo, ich habe gerade zwei Programme geschrieben, leider komme ich nicht weiter bezüglich der Fehlermeldungen:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include<stdio.h> int main() { printf("\nEin char belegt %d Bytes", sizeof( char )); printf("\nEin int belegt %d Bytes", sizeof( int )); printf("\nEin short belegt %d Bytes", sizeof( short )); printf("\nEin long belegt %d Bytes", sizeof( long )); printf("\nEin unsigned char belegt %d Bytes", sizeof( unsigned char )); printf("\nEin unsigned int belegt %d Bytes", sizeof( unsigned int )); printf("\nEin unsigned short belegt %d Bytes", sizeof( unsigned short )); printf("\nEin unsigned long belegt %d Bytes", sizeof( unsigned long )); printf("\nEin float belegt %d Bytes", sizeof( float )); printf("\nEin double belegt %d Bytes", sizeof( double )); return 0; } |
Fehlermeldung:
sizeof.c: In function ‘main’: sizeof.c:5:2: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’ sizeof.c:6:2: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’ sizeof.c:7:2: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’ sizeof.c:8:2: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’ sizeof.c:9:2: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’ sizeof.c:10:2: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’ sizeof.c:11:2: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’ sizeof.c:12:2: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’ sizeof.c:13:2: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’ sizeof.c:14:2: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | /* Zeigt Verwendung von Variablen und Konstanten */ #include<stdio.h> /* Konstante zur Umrechnung von Pfund in Gramm definieren */ #define GRAMM_PRO_PFUND 454 /* Konstante für Beginn des nächsten Jahrzehnts definieren */ const int ZIEL_JAHR = 2012; /* Erfolderliche Variablen deklarieren */ long gewicht_in_gramm, gewicht_in_pfund; int jahr_der_geburt, alter_in_2012; int main() { /* Daten vom Benutzer einlesen */ printf("\nBitte Ihr Gewicht in Gramm eingeben: "); scanf("%d", &gewicht_in_pfund); printf("\nBitte Ihr Geburtsjahr eingeben: "); scanf("%d", &jahr_der_geburt); /* Umrechnung durchführen */ gewicht_in_pfund = gewicht_in_gramm / GRAMM_PRO_PFUND; alter_in_2012 = ZIEL_JAHR - jahr_der_geburt; /* Ergebnisse auf Bildschirm ausgeben */ printf("\nIhr Gewicht in Pfund: %ld\n", gewicht_in_pfund); printf("\nIm Jahr 2012 sind Sie %d Jahre alt.\n", alter_in_2012); return 0; } |
Fehlermeldung:
konst.c: In function ‘main’: konst.c:18:2: warning: format ‘%d’ expects type ‘int *’, but argument 2 has type ‘long int *’
Normalerweise wird doch dem Datentyp int das Formatzeichen %d oder %i zugewiesen?! Warum klappt das denn nur nicht in Z.18 bzw. im kompletten ersten Programm?
Vll kann mir ja jemand helfen. Vielen Dank