Ich erhalte Warnungen kompilieren, aber ich weiß nicht, wie es zu beheben:'% d' erwartet Argument vom Typ 'int', aber Argument 2 hat Typ 'long unsigned int' [-Wformat =]
'%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [
Das Programm läuft gut, aber ich immer noch die Kompilierung Warnungen erhalten:
/* Sizeof.c--Program to tell byte size of the C variable */
#include <stdio.h>
int main(void) {
printf("\nA Char is %d bytes", sizeof(char));
printf("\nAn int is %d bytes", sizeof(int));
printf("\nA short is %d bytes", sizeof(short));
printf("\nA long is %d bytes", sizeof(long));
printf("\nA long long is %d bytes\n", sizeof(long long));
printf("\nAn unsigned Char is %d bytes", sizeof(unsigned char));
printf("\nAn unsigned int is %d bytes", sizeof(unsigned int));
printf("\nAn unsigned short is %d bytes", sizeof(unsigned short));
printf("\nAn unsigned long is %d bytes", sizeof(unsigned long));
printf("\nAn unsigned long long is %d bytes\n",
sizeof(unsigned long long));
printf("\nfloat is %d bytes", sizeof(float));
printf("\nA double is %d bytes\n", sizeof(double));
printf("\nA long double is %d bytes\n", sizeof(long double));
return 0;
}
In GCC 4.8.1 unter Windows bekomme ich einen Fehler: "unbekanntes Konvertierungstyp Zeichen 'z' im Format" beim Drucken% zu. –
@CzarekTomczak aktualisierte Antwort, wahrscheinlich verwandt. –
Danke Shafik. Leider ist nichts davon plattformübergreifend. Ich muss size_t auf (unsigned long) setzen, damit der Code sowohl unter Linux als auch unter Windows funktioniert. Unter Linux wird bei der Verwendung von% Iu (I als Integer) der Fehler "Format '% u' erwartet das Argument vom Typ 'unsigned int'". –