This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

atof() function problem + sprintf()

I am using keil IDE for arm7 (LPC2138 by NXP) programming.
Here is my code.
>>
#include <LPC213X.H>
#include "Stdlib.h"
#include "Serial.h"
void initialize(void);
int main () { float number; int i;

initialize(); UART0_sendstring("Here 1\r\n");

number = atof("643.783");

UART0_sendstring("Here 2\r\n");

while(1){}
}

Program compiles successfully.Only 2 warnings:
main_testProj2.c(51): warning: #550-D: variable "number" was set but never used
main_testProj2.c(52): warning: #177-D: variable "i" was declared but never referenced

Now when i simulate the code on Hardware. Only "Here 1\r\n" string is displayed on HyperTerm. "Here2\r\n" is not Displayed at All.
If i replace the argument string of atof() with something like this >> number = atof("6.3e+2");
then the program works fine. Both the strings are displayed in respective order.

What i concluded:
In first case, The program enters into the atof function but it never comes back, looks like it hangs somewhere inside the atof() function. Why?
Also i have found that similar problem occurs when i use sprintf function to convert float to string.

Parents Reply Children
No data