- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to build code for the Psoc5 that uses the itoa function from stdlib.h.
I have the #include <stdlib.h> at the beginning of main.c but It is not being included and I am getting errors related to
undefined references to itoa. Do I need to explicitly set the include path in the build settings? and if so where would they be located.
Thanks
Solved! Go to Solution.
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi r2park,
If you are intending to convert from integer to ASCII string, then did you try using the sprintf( ) function to do the same?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi r2park,
If you are intending to convert from integer to ASCII string, then did you try using the sprintf( ) function to do the same?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, as a matter of fact I use "#include <stdlib.h>" in a PSoC5 - project without any error-message. You should check for
An installation-error
An error occuring BEFORE the #include (mismatched brckets, missing semicolon...)
A search reveiled 4 files named "stdio.h" one for each compiler (Keil, GNU 4, GNU generic, GNU ++)
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello there. As Bob has pointed out, you can include stdlib.h without any issues. However, note that i2a may not be a standard C function. The best possible solution is to use, sprintf if what you are trying to achieve is integer to ascii conversion.
You can do it as follows,
sprintf(buffer, sizeof(buffer), "%d", i);
your ascii result is now present in the buffer. You might have to include stdio.h in order to use sprintf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, the sprintf function works great. I had assumed that the itoa was a standard function due to atoi being in stlib.h