User Profile
Collapse
-
Thanks, I am trying to program a "Rabbit" mcu and it uses a language called Dynamic C, which is JUST like C. Your suggestion with the N4 - 48 worked. I think the problem is like you say, atoi() is looking for a null terminated string and when I pass it a single character it is not null terminated... -
Converting a char to an int
I am trying use the following code to convert a char to an int but it's not working.
For some reason PosToMoveTo contains 4000 instead of 4. I am not sure why...
main()
{
int i;
int dis;
char * Distance;
char N0, N1, N2, N3, N4;
int PosToMoveTo;
ReceivedStr = "P0004";
N0 = ReceivedStr[0];
N1 = ReceivedStr[1];... -
-
Passing strings to and from functions
I am trying to pass a string to a Mid() function, return a portion of the string, and then convert that portion to an int. My attempt looks like this..
char * ReceivedStr;
char * Mid(char * inString, int Start, int Length );
main()
{
int i;
int dis;
char * Distance;
ReceivedStr = "Move125";
Distance = Mid(ReceivedStr , 4, 3);...
No activity results to display
Show More
Leave a comment: