<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: I am having trouble with sprintf when using it with char... in Classic/Legacy CodeWarrior</title>
    <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/I-am-having-trouble-with-sprintf-when-using-it-with-char/m-p/197613#M5203</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I don't know what is causing your problems, but I do know that sprintf() should be regarded as a hobbyist function only. There are multiple problems with that function: poor execution speed, huge nvm memory consumption, no thread safety, poor standardization of va_arg lists, and so on. As I see it, the only reason it is available is because Codewarrior want to claim ISO C compliance.&lt;BR /&gt;&lt;BR /&gt;Professional embedded programmers will use their own int to string conversion routines.&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Oct 2008 21:33:55 GMT</pubDate>
    <dc:creator>Lundin</dc:creator>
    <dc:date>2008-10-29T21:33:55Z</dc:date>
    <item>
      <title>I am having trouble with sprintf when using it with char...</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/I-am-having-trouble-with-sprintf-when-using-it-with-char/m-p/197609#M5199</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am having trouble with sprintf when using it with char arrays instead of char pointers even when I use typecasting.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; char tmpstr[16];&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; sprintf((char *)tmpstr, " %X", 1024);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I get a string with %X in it instead of 400.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not a 'C' guru by any stretch.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Bob&lt;/SPAN&gt;&lt;BR /&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Oct 2008 04:11:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/I-am-having-trouble-with-sprintf-when-using-it-with-char/m-p/197609#M5199</guid>
      <dc:creator>bob_s</dc:creator>
      <dc:date>2008-10-28T04:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: I am having trouble with sprintf when using it with char...</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/I-am-having-trouble-with-sprintf-when-using-it-with-char/m-p/197610#M5200</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Which processor, which code warrior version are you using?&lt;BR /&gt;The code looks fine as far as I can tell.&lt;BR /&gt;I saw in this forum that ColdFire is using a specially small version of printf in some case, see the thread referenced below, or search for ColdFire and printf at the bottom of this page.&lt;BR /&gt;Daniel&lt;BR /&gt;&lt;A href="http://forums.freescale.com/freescale/board/message?board.id=CWCFCOMM&amp;amp;message.id=2282" target="_blank"&gt;&lt;BR /&gt;http://forums.freescale.com/freescale/board/message?board.id=CWCFCOMM&amp;amp;message.id=2282&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;BTW: For "just" converting an int to its hex representation, then probably&lt;BR /&gt;a dedicated function for that is much more (code and speed) effective than using printf.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Oct 2008 05:09:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/I-am-having-trouble-with-sprintf-when-using-it-with-char/m-p/197610#M5200</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2008-10-28T05:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: I am having trouble with sprintf when using it with char...</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/I-am-having-trouble-with-sprintf-when-using-it-with-char/m-p/197611#M5201</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I am running CW 8.1.1a.&lt;BR /&gt;&lt;BR /&gt;I'm sure you are right.&amp;nbsp; The original line of code was:&lt;BR /&gt;sprintf(tmpstr, "%X",(NVRAM_ADDR + (i * DATA_FLASH_SECTOR_SIZE)));&lt;BR /&gt;which I was using to report block data for troubleshooting flash erase and writes.&lt;BR /&gt;&lt;BR /&gt;However I use sprintf to combine strings and ints into printable info for serial port echoes.&amp;nbsp; I'm concerned there will be bugs in other sections of code.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Do you think I should use alternative routines for all sprintf calls?&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Oct 2008 19:58:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/I-am-having-trouble-with-sprintf-when-using-it-with-char/m-p/197611#M5201</guid>
      <dc:creator>bob_s</dc:creator>
      <dc:date>2008-10-28T19:58:04Z</dc:date>
    </item>
    <item>
      <title>Re: I am having trouble with sprintf when using it with char...</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/I-am-having-trouble-with-sprintf-when-using-it-with-char/m-p/197612#M5202</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;For the record,&amp;nbsp; by removing the sprintf lines:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sprintf(tmpstr, "%X",(NVRAM_ADDR + (i * DATA_FLASH_SECTOR_SIZE)));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sprintf(TxSplrBuf1, "%s %s\r", tmpstr, msg);&lt;BR /&gt;&lt;BR /&gt;from different spots in my code and adding a routines to do the conversions, my problems went away.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I use sprintf other places in code without problems.&amp;nbsp; I am running low on FLASH ROM, though I have plenty of RAM.&amp;nbsp; I don't know it that is part of the problem.&lt;BR /&gt;&lt;BR /&gt;Thanks for the help.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Oct 2008 04:22:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/I-am-having-trouble-with-sprintf-when-using-it-with-char/m-p/197612#M5202</guid>
      <dc:creator>bob_s</dc:creator>
      <dc:date>2008-10-29T04:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: I am having trouble with sprintf when using it with char...</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/I-am-having-trouble-with-sprintf-when-using-it-with-char/m-p/197613#M5203</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I don't know what is causing your problems, but I do know that sprintf() should be regarded as a hobbyist function only. There are multiple problems with that function: poor execution speed, huge nvm memory consumption, no thread safety, poor standardization of va_arg lists, and so on. As I see it, the only reason it is available is because Codewarrior want to claim ISO C compliance.&lt;BR /&gt;&lt;BR /&gt;Professional embedded programmers will use their own int to string conversion routines.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Oct 2008 21:33:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/I-am-having-trouble-with-sprintf-when-using-it-with-char/m-p/197613#M5203</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2008-10-29T21:33:55Z</dc:date>
    </item>
  </channel>
</rss>

