<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/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/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>How to declare a string</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/58313/how-to-declare-a-string</link><description>I have a list of characters and trying to put them in a string. 
 char line[13]; /* Line buffer */ 
 NRF_LOG_INFO(&amp;quot;Playlist : %c&amp;quot;, line[0]); this works displaying 1 character at a time 
 NRF_LOG_INFO(&amp;quot;Playlist : %s&amp;quot;, line); does not work displaying the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 27 Feb 2020 15:53:47 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/58313/how-to-declare-a-string" /><item><title>RE: How to declare a string</title><link>https://devzone.nordicsemi.com/thread/236948?ContentTypeID=1</link><pubDate>Thu, 27 Feb 2020 15:53:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8f258039-d272-4f08-90e1-d75731a8678e</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;That is strange. Could you try to do the same in a really simple example, E.g.&amp;nbsp;add those lines&amp;nbsp;to&amp;nbsp;&lt;em&gt;examples\peripheral\temperature &lt;/em&gt;and check if the result is similar. If it still doesn&amp;#39;t work, could you try to build the example using another compiler/IDE. E.g. try opening&amp;nbsp;&lt;em&gt;\examples\peripheral\temperature\pca10056\blank\armgcc&amp;nbsp;&lt;/em&gt;and run these commands:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;make&lt;/li&gt;
&lt;li&gt;make flash&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Open Termite and check the result.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to declare a string</title><link>https://devzone.nordicsemi.com/thread/236938?ContentTypeID=1</link><pubDate>Thu, 27 Feb 2020 15:27:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6c768295-71e9-4547-839f-d321dc3cb65c</guid><dc:creator>Rick Z</dc:creator><description>&lt;p&gt;The result back in log is as follow&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; app: Playing PLAYLIST &lt;br /&gt;&amp;lt;info&amp;gt; app: test 1  &lt;br /&gt;&amp;lt;info&amp;gt; app: I2S loopback example started.&lt;/p&gt;
&lt;p&gt;next to test 1 is a weird character&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    char line[4]= {0x48, 0x45, 0x59, NULL}; /* Line buffer */
    NRF_LOG_INFO(&amp;quot;test 1 %s&amp;quot;, line);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to declare a string</title><link>https://devzone.nordicsemi.com/thread/236921?ContentTypeID=1</link><pubDate>Thu, 27 Feb 2020 14:55:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a763245f-9140-4183-b342-b78589d7faad</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Can you provide your whole code? Or at least the source (.c) file where you assign values to &lt;em&gt;line[].&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to declare a string</title><link>https://devzone.nordicsemi.com/thread/236916?ContentTypeID=1</link><pubDate>Thu, 27 Feb 2020 14:46:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b91d4b03-266b-4a12-bd78-537028cbdedc</guid><dc:creator>Rick Z</dc:creator><description>&lt;p&gt;Same as example i provided above which is essentially the same thing in your example&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to declare a string</title><link>https://devzone.nordicsemi.com/thread/236914?ContentTypeID=1</link><pubDate>Thu, 27 Feb 2020 14:45:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aeda25a8-85e7-4eee-b754-4bf5f784b863</guid><dc:creator>Rick Z</dc:creator><description>&lt;p&gt;Unfortunately it does not print this but instead a garbage character is printed&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to declare a string</title><link>https://devzone.nordicsemi.com/thread/236634?ContentTypeID=1</link><pubDate>Wed, 26 Feb 2020 16:44:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4e9d1f98-57f9-46ee-b510-8cf2c9cf3be0</guid><dc:creator>Simon</dc:creator><description>[quote user=""]NRF_LOG_INFO(&amp;quot;Playlist : %s&amp;quot;, line); does not work displaying the 13 character as a string[/quote]
&lt;p&gt;&amp;nbsp;If you use the placeholder %s, it will log all the bytes from the given address until it hits a NULL character. E.g the following (the characters are written as ASCII, convert it using &lt;a href="http://www.asciitable.com/"&gt;http://www.asciitable.com/&lt;/a&gt;):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;char line[4]= {0x48, 0x45, 0x59, NULL}; /* Line buffer */
NRF_LOG_INFO(&amp;quot;%s&amp;quot;, line);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Will print:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;info&amp;gt; app: HEY&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If you have a NULL character in the middle of the string, it will only print the characters up to that point.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>