Hi, my program does not do the expected things, printf a unsigned long long int.
#include <aduc7026.h> #include"stdio.h" void RS232_init(void); int main (void) { unsigned long long int A; RS232_init(); printf("Start \n"); while(1) { while(1) { printf("Enter a Hex-number\n"); if (scanf("%X",&A)) break; scanf("%*"); //Clearing scanf input stream } printf ("Your input %64.64lX\n",A); A *= A; printf ("The result %64.64lX\n",A); } } void RS232_init(void) { GP1CON = 0x011; // Setup tx & rx pins on P1.0 and P1.1 // Start setting up UART at 9600bps COMCON0 = 0x080; // Setting DLAB COMDIV0 = 0x088; // Setting DIV0 and DIV1 to DL calculated COMDIV1 = 0x000; COMCON0 = 0x007; // Clearing DLAB }
printf ("Your input %64.64lX\n",A);
I just want to force printf to give me unsigned long long integer for example 0x11111111 * 0x11111111 i expect 0x0123456787654321 but the result from printf is only 000000000087654321. What a mess! I'am very very disapointed! Maybe the compiler does not recognize "unsigned long long integer"? But there's no error-message! Who can help?
I just want to force printf to give me unsigned long long integer Then why are you telling printf that the length is long integer (l) instead of long long integer (ll) ?
View all questions in Keil forum