Hi, im new here, and Im doing a proyect which happens that i need to change a string to integer.
On C eclipse works fine however on Freescale doesnt do anything.
Pleace help
I create a new proyect apart just to see ATOI working properly. I was able to see that the variable "number" changes from 4 to cero, as if nothing got atoi and if I uncoment the atof line i geet the error Symbol strtod ... is undefined.
Please advice (version of my codewarrior is V6.3 build 9279
This is the code:
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char y[] @0x0068 ="12";
char f[] @0x0070 ="143.343";
int number @0x0060 =4;
double flot;
void main(void) {
EnableInterrupts; /* enable interrupts */
/* include your code here */
for(;;) {
__RESET_WATCHDOG(); /* feeds the dog */
number=atoi((const char*)y); /// also like this doesnt work : number=atoi(y);
//flot = atof((const char*)f);
} /* loop forever */
/* please make sure that you never leave main */
}
已解决! 转到解答。
Hi Gus,
You can use function atoi() directly in your application.
See attached example project for reference.
Have a great day,
Zhang Jun
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Gus,
You can use function atoi() directly in your application.
See attached example project for reference.
Have a great day,
Zhang Jun
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi
1. QG8 default project allocates 0x40 bytes RAM to stack. while atoi and atof is very memory consuming. so you need increase the stack size.
2. use atof, you need use floating support.
see attached demo code and screenshot.
Have a great day,
Zhang Jun
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
You are welcome ! :-)
Have a great day,
Zhang Jun
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Gus,
please create a new thread for the new questions. I will check. thanks!
Have a great day,
Zhang Jun
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
you are welcome! :-)
Have a great day,
Zhang Jun
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------