TI E2E Community
TI C/C++ Compiler
TI C/C++ Compiler - Forum
something is not right in sprintf function ?
I have a code like below:
int a; char cc;
if I use sprintf(cc,"%03ld", (long)a); --->version 2
then cc='1'. that is what I expect.
My CCS version is 22.214.171.124. Do you have to cast before using sprint ?
This could depend on the int and long representation of your target machine and compiler implementation.
Is sizeof(int)==sizeof(long) ?
Have you already tried "%03d" (without the 'l')?
Alberto has the right answer here. Note that even if "int" and "long" have the same representation, a program which passes "int" to printf where a "long" is expected is not a strictly conforming program.
All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.
TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs andembedded processors, along with software, tools and the industry’s largest sales/support staff.