AnsweredAssumed Answered

simple atoi() function on CF V1

Question asked by Michel Leger on Apr 26, 2012
Latest reply on Apr 26, 2012 by Michel Leger

Hi group,


I have just ran into a snag that I dearly hope has an easy fix.

Have been using the MCF51AC256 on a project for a while now and all is great... so far.


The problem is this.


I have an ASCII string coming in from the serial port that is obviously stored into a char array in ram , say char tempbuf[100].

The application needs to convert this string of 0 to 9 into an integer. Simple right?

When I use the standard library atoi() function, I get compile errors because it actually wants a constant string from code space as if any and all application of atoi() would be in the atoi("12345") format instead of atoi(tempbuf[0]) .

Digging into it, the atoi is actually a define that points to strtol() function and it expects a const string ptr* (rom based from my understanding) as opposed to my RAM based string ptr*.


Is there a quick fix to tell the function to get it's const from ram instead?


I hope my somewhat limited knowledge of the standard MSL is at fault here.

Thank you in advance for your help.