From: ALEXANDRE M. <al...@ae...> - 2009-02-10 10:38:10
|
Hello everyone. I had a problem working with float and integer numbers in SDCC using the sprintf function. Here the important parts of code: char buff[]; // global variable ... void main(void) } .... sprintf(buff,"KEY released. %f %d %c %s \r\n",18.25, 125, 'C', "bla"); USARTsendString(buff); ... } // end main function in sprintf function I try to print many data types to a string and send it through serial port to a PC. the result is: KEY released. <NO FLOAT> ? C bla. I tried also this way: void main (void) { ... float fl1 = 18.725; int INT = 18725; char str[10] = "bla"; char ch = 'C'; ... sprintf(buff,"KEY released. %f %d %c %s \r\n",fl1, INT, ch, str); ... } same result: KEY released. <NO FLOAT> ? C bla. I included stdio.h and stdlib.h header files. There is a specific way to pass the arguments to this function? Anyone had the same problem? Is there a way to solve this. Thanks in advance for your help. Best regards Alexandre Martins --------------------------------------------------- Nao perca as melhores sugestoes para o Dia dos Namorados! Saiba tudo em http://cupido.aeiou.pt/ |