I have failed the source line .
I'm using the M52233DEMO board and the CodeWarrior 6.3 Special edition.
Now there is the correct code for printf test and the output on the UART console.
.
/*
* File: main.c
* Purpose: sample program
*
*/
#include <stdio.h>
char sf[80];
int i = 25;
char c = 'M';
short int d = 'm';
static char s[] = "Metrowerks!";
static char pas[] = "\pMetrowerks again!";
float f = 3.1415926;
double x = 3.1415926;
int count;
int fi;
int xi;
float input_f;
int main()
{
int count;
printf("\n\r---------------------------------------\n\r");
printf("Hello World 2 in C\n\r");
fflush(stdout);
printf("\n\r\n\r");
printf("%s printf() demonstration:\n\r%n", s, &count);
printf("The last line contained %d characters\n\r",count);
printf("Pascal string output: %#20s\n\r", pas);
printf("%-4d 0x%x 0x%06x %-5o\n\r", i, i, i, i);
printf("%*d\n", 5, i);
printf("%4c %4u %4.10d\n\r", c, c, c);
printf("%4c %4hu %3.10hd\n\r", d, d, d);
printf("$%5.2f\n\r", f);
fi=(int)(f*100000000.);
xi=(int)(x*100000000.);
printf("fi (int)(x*1000000000.)=%d\n\r",fi);
printf("xi (int)(x*1000000000.)=%d\n\r",xi);
printf("input float : ");
scanf("%f",&input_f);
printf("\n\r inputf*1000=%d\n\r",(int)(input_f*1000.));
fflush(stdout);
while(1); // Idle
return 0;
}
---------------------------------------
Hello World 2 in C
Metrowerks! printf() demonstration:
The last line contained 37 characters
Pascal string output: Metrowerks again!
25 0x19 0x000019 31
25
M 77 0000000077
m 109 0000000109
$%5.2f
fi (int)(x*1000000000.)=314159250
xi (int)(x*1000000000.)=314159260
input float :
inputf*1000=0
The red line is wrong : should be 3.14
And the scanf also is'nt OK : should be waiting for input from UART console.