<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>efficient varied string table</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/19751/efficient-varied-string-table</link><description> 
Please help. I have been struggling for too long on this. How do I
use printf to print any of the messages? 

 
Is this the best way to use a table of varying length strings or
is a struct devicestates {}; better, or must I specify fixed length
strings</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: efficient varied string table</title><link>https://community.arm.com/thread/47165?ContentTypeID=1</link><pubDate>Sat, 04 Nov 2006 04:16:01 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:9d183e3e-61be-46b1-95b1-6914db1b854c</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;Is this the best way...&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Depends on what you mean by &amp;quot;best&amp;quot;&lt;/p&gt;

&lt;p&gt;
It is certainly a very bad way if you are concerned to minimise
the amount of storage used!&lt;/p&gt;

&lt;p&gt;
The whole point of arrays is that every element is the same - in
your case, the strings vary greatly in length, so the short ones will
be padded to the length of the longest ones.&lt;br /&gt;
This wastes a lot of space - which may or may not be important to
you.&lt;/p&gt;

&lt;p&gt;
You could avoid this by using &lt;b&gt;pointers&lt;/b&gt; to the strings
instead; eg,&lt;/p&gt;

&lt;pre&gt;
char *DeviceStates[4][2] =
{
  {&amp;quot;closed&amp;quot;, &amp;quot;open&amp;quot;},
  {&amp;quot;down&amp;quot;, &amp;quot;up&amp;quot;},
  {&amp;quot;on;&amp;quot;, &amp;quot;off&amp;quot;},
  {&amp;quot;say not implemented;&amp;quot;, &amp;quot;say is implemented;&amp;quot;}
};
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>