<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>stl string and allegro text functions</title>
		<link>http://www.allegro.cc/forums/view/587873</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sun, 08 Oct 2006 20:07:39 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>When the user presses a key, how could I append these to a stl string variable. I&#39;ve tried:</p><div class="source-code snippet"><div class="inner"><pre>  <span class="k1">if</span><span class="k2">(</span><a href="http://www.allegro.cc/manual/keypressed" target="_blank"><span class="a">keypressed</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">)</span>
  <span class="k2">{</span>
    k <span class="k3">=</span> <a href="http://www.allegro.cc/manual/readkey" target="_blank"><span class="a">readkey</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>

    <span class="c">//append the key to the end of the string</span>
    m_text.insert<span class="k2">(</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_470.html" target="_blank">index</a>, k <span class="k3">&amp;</span> <span class="n">0xff</span><span class="k2">)</span><span class="k2">;</span>
  <span class="k2">}</span>
</pre></div></div><p>

But it doesn&#39;t seem to work. Any ideas?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Rick)</author>
		<pubDate>Wed, 04 Oct 2006 19:37:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>This is really a guess, since I don&#39;t use C++, but...</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">if</span><span class="k2">(</span><a href="http://www.allegro.cc/manual/keypressed" target="_blank"><span class="a">keypressed</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">)</span>
<span class="k2">{</span>
            k <span class="k3">=</span> <a href="http://www.allegro.cc/manual/readkey" target="_blank"><span class="a">readkey</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
            string str <span class="k2">(</span><span class="n">1</span>, k <span class="k3">&amp;</span> <span class="n">0xff</span><span class="k2">)</span><span class="k2">;</span>

            <span class="c">//append the key to the end of the string</span>
            m_text.insert<span class="k2">(</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_470.html" target="_blank">index</a>, str<span class="k2">)</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (LennyLen)</author>
		<pubDate>Wed, 04 Oct 2006 19:53:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It compiles but it blows up on m_text.insert(index, str); for some reason.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Rick)</author>
		<pubDate>Wed, 04 Oct 2006 20:17:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hmmm, maybe you might want to <tt>cout &lt;&lt; str;</tt> to check that the way I created it actually was valid.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (LennyLen)</author>
		<pubDate>Wed, 04 Oct 2006 20:24:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It works in I put something in m_text first. If m_text doesn&#39;t have anything then it gives the error.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Rick)</author>
		<pubDate>Wed, 04 Oct 2006 20:26:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>This may be an obvious question, but what is the value of index? (I&#39;ve been using C#/Java strings/Strings for to long so I&#39;ve been used to them just working(tm))
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Hard Rock)</author>
		<pubDate>Wed, 04 Oct 2006 20:26:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Starts out at 0 and gets incremented as you go. If I put for example:</p><p>m_text = &quot;Test&quot;;</p><p>in the constructor everything works fine, but of course I don&#39;t want anything to start with.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Rick)</author>
		<pubDate>Wed, 04 Oct 2006 20:32:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>remember, strings are immutable. If you want to update strings, you should really use the stringbuffer
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Walker)</author>
		<pubDate>Wed, 04 Oct 2006 20:40:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If I understood everything correctly, this should do it:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">if</span><span class="k2">(</span><a href="http://www.allegro.cc/manual/keypressed" target="_blank"><span class="a">keypressed</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">)</span>
<span class="k2">{</span>
  k <span class="k3">=</span> <a href="http://www.allegro.cc/manual/readkey" target="_blank"><span class="a">readkey</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
  m_text <span class="k3">+</span><span class="k3">=</span> <span class="k2">(</span>k <span class="k3">&amp;</span> <span class="n">0xff</span><span class="k2">)</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Hano Wair)</author>
		<pubDate>Wed, 04 Oct 2006 20:41:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
If you want to update strings, you should really use the stringbuffer
</p></div></div><p>

Never used them before. Some searching on C++ StringBuffer seems to bring up more java stuff than C++.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Rick)</author>
		<pubDate>Wed, 04 Oct 2006 20:48:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="source-code snippet"><div class="inner"><pre><span class="k1">if</span><span class="k2">(</span><a href="http://www.allegro.cc/manual/keypressed" target="_blank"><span class="a">keypressed</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">)</span>
<span class="k2">{</span>
            k <span class="k3">=</span> <a href="http://www.allegro.cc/manual/readkey" target="_blank"><span class="a">readkey</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>

            <span class="c">//insert the key at index</span>
            m_text.insert<span class="k2">(</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_470.html" target="_blank">index</a>, <span class="n">1</span>, k <span class="k3">&amp;</span> <span class="n">0xff</span><span class="k2">)</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>
Also do checks to see if index is valid.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ImLeftFooted)</author>
		<pubDate>Wed, 04 Oct 2006 20:54:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Dustin, that doesn&#39;t work unless I put something in m_text first like m_text=&quot;Test&quot;; Why is that?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Rick)</author>
		<pubDate>Wed, 04 Oct 2006 20:55:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Your index variable would be something invalid.</p><p>See if this code works
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">if</span><span class="k2">(</span><a href="http://www.allegro.cc/manual/keypressed" target="_blank"><span class="a">keypressed</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">)</span>
<span class="k2">{</span>
            k <span class="k3">=</span> <a href="http://www.allegro.cc/manual/readkey" target="_blank"><span class="a">readkey</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>

            <span class="c">//insert the key at index</span>
            m_text.insert<span class="k2">(</span><span class="n">0</span>, <span class="n">1</span>, k <span class="k3">&amp;</span> <span class="n">0xff</span><span class="k2">)</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>

Btw, there is a reason that you&#39;re not using the append function right?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ImLeftFooted)</author>
		<pubDate>Wed, 04 Oct 2006 20:57:17 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>My index value is 0. I step through the code to see this. It still doesn&#39;t work unless I put something in m_text on init.</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="k1">class</span> Textbox</td></tr><tr><td class="number">2</td><td><span class="k2">{</span></td></tr><tr><td class="number">3</td><td>private:</td></tr><tr><td class="number">4</td><td>  string m_text<span class="k2">;</span></td></tr><tr><td class="number">5</td><td>  <span class="k1">int</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_470.html" target="_blank">index</a><span class="k2">;</span></td></tr><tr><td class="number">6</td><td>public:</td></tr><tr><td class="number">7</td><td>  Textbox<span class="k2">(</span><span class="k2">)</span></td></tr><tr><td class="number">8</td><td>  <span class="k2">{</span></td></tr><tr><td class="number">9</td><td>    <a href="http://www.delorie.com/djgpp/doc/libc/libc_470.html" target="_blank">index</a> <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span></td></tr><tr><td class="number">10</td><td>  <span class="k2">}</span></td></tr><tr><td class="number">11</td><td>  string getText<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">12</td><td>  <span class="k1">void</span> poll<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">13</td><td>  <span class="k1">void</span> draw<span class="k2">(</span><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a><span class="k3">*</span> buffer<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">14</td><td><span class="k2">}</span><span class="k2">;</span></td></tr><tr><td class="number">15</td><td>&#160;</td></tr><tr><td class="number">16</td><td><span class="k1">void</span> Textbox::poll<span class="k2">(</span><span class="k2">)</span></td></tr><tr><td class="number">17</td><td><span class="k2">{</span></td></tr><tr><td class="number">18</td><td>  <span class="k1">int</span> k<span class="k2">;</span></td></tr><tr><td class="number">19</td><td>&#160;</td></tr><tr><td class="number">20</td><td>  <span class="k1">if</span><span class="k2">(</span><a href="http://www.allegro.cc/manual/keypressed" target="_blank"><span class="a">keypressed</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">)</span></td></tr><tr><td class="number">21</td><td>  <span class="k2">{</span></td></tr><tr><td class="number">22</td><td>    k <span class="k3">=</span> <a href="http://www.allegro.cc/manual/readkey" target="_blank"><span class="a">readkey</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">23</td><td>    string str <span class="k2">(</span><span class="n">1</span>, k <span class="k3">&amp;</span> <span class="n">0xff</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">24</td><td>&#160;</td></tr><tr><td class="number">25</td><td>    <span class="c">//append the key to the end of the string</span></td></tr><tr><td class="number">26</td><td>    m_text.insert<span class="k2">(</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_470.html" target="_blank">index</a>, str<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">27</td><td>    <a href="http://www.delorie.com/djgpp/doc/libc/libc_470.html" target="_blank">index</a><span class="k3">+</span><span class="k3">+</span><span class="k2">;</span></td></tr><tr><td class="number">28</td><td>  <span class="k2">}</span></td></tr><tr><td class="number">29</td><td><span class="k2">}</span></td></tr></tbody></table></div></div><p>


Because I don&#39;t know much about the string class. <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Rick)</author>
		<pubDate>Wed, 04 Oct 2006 20:59:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
remember, strings are immutable. If you want to update strings, you should really use the stringbuffer
</p></div></div><p>

Wrong language.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (X-G)</author>
		<pubDate>Wed, 04 Oct 2006 21:39:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Wrong language.
</p></div></div><p>

That explains it. Maybe I&#39;ll just use good old C with the details here.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Rick)</author>
		<pubDate>Wed, 04 Oct 2006 22:24:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>This is (basically) what I do. Works like a charm.</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> UIInputBox::handleCharPress<span class="k2">(</span><span class="k1">int</span> k<span class="k2">)</span> <span class="k2">{</span>
  text.insert<span class="k2">(</span>cursor, string<span class="k2">(</span><span class="n">1</span>, <span class="k2">(</span><span class="k1">char</span><span class="k2">)</span>k<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
  cursor<span class="k3">+</span><span class="k3">+</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (X-G)</author>
		<pubDate>Wed, 04 Oct 2006 22:28:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You can use push_back on a string, as it&#39;s also a Sequence.
</p><div class="source-code snippet"><div class="inner"><pre>string s<span class="k2">;</span>
s.push_back<span class="k2">(</span><span class="s">'X'</span><span class="k2">)</span><span class="k2">;</span>
s.push_back<span class="k2">(</span><span class="s">'-'</span><span class="k2">)</span><span class="k2">;</span>
s.push_back<span class="k2">(</span><span class="s">'G'</span><span class="k2">)</span><span class="k2">;</span>
cout <span class="k3">&lt;</span><span class="k3">&lt;</span> s <span class="k3">&lt;</span><span class="k3">&lt;</span> endl<span class="k2">;</span>
</pre></div></div><p>

The STL thing that&#39;s most like a StringBuffer is a <a href="http://www.sgi.com/tech/stl/Rope.html">Rope</a> I think.</p><p>Pete
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Hull)</author>
		<pubDate>Wed, 04 Oct 2006 22:57:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="source-code snippet"><div class="inner"><pre>std::string str <span class="k3">=</span> <span class="s">"abc"</span><span class="k2">;</span>
str <span class="k3">+</span><span class="k3">=</span> <span class="s">'d'</span><span class="k2">;</span>
</pre></div></div><p>

That is the standard for appending characters to strings AFAIK...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (netcat)</author>
		<pubDate>Wed, 04 Oct 2006 23:52:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Why would it be that if I don&#39;t do anything to the string variable it fails, and if I set the variable to anything first, then it works. ie. </p><p>string var;</p><p>var.insert(1, &#39;d&#39;);</p><p>doesn&#39;t seem to work but</p><p>string var;</p><p>var = &quot;Test&quot;;</p><p>var.insert(1, &#39;d&#39;);</p><p>works
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Rick)</author>
		<pubDate>Thu, 05 Oct 2006 01:37:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>
Because 1 is beyond the end of the empty string?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (X-G)</author>
		<pubDate>Thu, 05 Oct 2006 01:42:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That&#39;s what I was thinking, so I did a reserve() but that didn&#39;t seem to work. Not sure what direction to go in now. I guess I thought it would grow automatically.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Rick)</author>
		<pubDate>Thu, 05 Oct 2006 01:45:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Reserve doesn&#39;t matter if you&#39;re trying to insert something in a space that&#39;s beyond the size of the string. That would leave one character in between what you are trying to insert and the beginning of the string, which should be... what exactly?</p><p>Does the code I posted work?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (X-G)</author>
		<pubDate>Thu, 05 Oct 2006 01:51:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I don&#39;t see the difference between the code you posted and the code I have. So I would say yes if I assign text to something to begin with and no if I don&#39;t.</p><p>Your code
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> UIInputBox::handleCharPress<span class="k2">(</span><span class="k1">int</span> k<span class="k2">)</span> <span class="k2">{</span>
  text.insert<span class="k2">(</span>cursor, string<span class="k2">(</span><span class="n">1</span>, <span class="k2">(</span><span class="k1">char</span><span class="k2">)</span>k<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
  cursor<span class="k3">+</span><span class="k3">+</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>

My code
</p><div class="source-code snippet"><div class="inner"><pre>  k <span class="k3">=</span> <a href="http://www.allegro.cc/manual/readkey" target="_blank"><span class="a">readkey</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
    string str <span class="k2">(</span><span class="n">1</span>, k <span class="k3">&amp;</span> <span class="n">0xff</span><span class="k2">)</span><span class="k2">;</span>

    <span class="c">//append the key to the end of the string</span>
    m_text.insert<span class="k2">(</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_470.html" target="_blank">index</a>, str<span class="k2">)</span><span class="k2">;</span>
    <a href="http://www.delorie.com/djgpp/doc/libc/libc_470.html" target="_blank">index</a><span class="k3">+</span><span class="k3">+</span><span class="k2">;</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Rick)</author>
		<pubDate>Thu, 05 Oct 2006 01:58:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>
Read what I said. You&#39;re trying to <i>insert text in an index that is beyond the length of the string.</i> That&#39;s not <b>supposed</b> to work.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (X-G)</author>
		<pubDate>Thu, 05 Oct 2006 02:01:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>OK, so no, your example doesn&#39;t work. How do I increase the length of the string?</p><p>[EDIT}<br />+= should work I think <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /><br />or push_back(), or maybe append()</p><p>I think that is what you were trying to get me to find <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Rick)</author>
		<pubDate>Thu, 05 Oct 2006 02:07:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
How do I increase the length of the string?
</p></div></div><p>

Put something on the end. Or insert at index 0, which is just at the end of the string, and not 1 index into oblivion.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (X-G)</author>
		<pubDate>Thu, 05 Oct 2006 02:19:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Oh well that&#39;s not what I expected because my index does start at 0 and that didn&#39;t work for me.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Rick)</author>
		<pubDate>Thu, 05 Oct 2006 02:22:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Maybe you&#39;re misinterpretting the crash.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ImLeftFooted)</author>
		<pubDate>Thu, 05 Oct 2006 02:54:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Wrong language.
</p></div></div><p>This is the problem when you have to code in 5 languages at once per day <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Walker)</author>
		<pubDate>Thu, 05 Oct 2006 16:20:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Which compiler can accept five languages at once, being java one of them? <img src="http://www.allegro.cc/forums/smileys/huh.gif" alt="???" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Rampage)</author>
		<pubDate>Fri, 06 Oct 2006 02:50:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Which compiler can accept five languages at once, [java being] one of them? <img src="http://www.allegro.cc/forums/smileys/huh.gif" alt="???" />
</p></div></div><p>
gcc
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ImLeftFooted)</author>
		<pubDate>Fri, 06 Oct 2006 03:39:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>At once? I thought it could compile only one language at a time <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Rampage)</author>
		<pubDate>Fri, 06 Oct 2006 04:15:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
How do I increase the length of the string?
</p></div></div><p>
resize(). reserve() is generally worthless.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (23yrold3yrold)</author>
		<pubDate>Fri, 06 Oct 2006 09:13:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Of course, you know I meant separately. But the .NET compiler supports about 20 or so languages at present and you can mix your code if you wish.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Walker)</author>
		<pubDate>Fri, 06 Oct 2006 14:54:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>some times to get strings to work with allegro you need to convert then to a string of chars using the .c-str()  example:  stringName.c-str()</p><p>also when you add 2 string the have to be blank or have something in them.</p><p>example of a blank string : stringName = &quot;&quot;;
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (piccolo)</author>
		<pubDate>Fri, 06 Oct 2006 15:45:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I had problems with Allegro and std::string before, and due to this I always called <span class="source-code"><a href="http://www.allegro.cc/manual/set_uformat" target="_blank"><span class="a">set_uformat</span></a><span class="k2">(</span>U_ASCII<span class="k2">)</span><span class="k2">;</span></span> once to have Allegro play well with std::string.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Michael Faerber)</author>
		<pubDate>Fri, 06 Oct 2006 19:49:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
+= should work I think <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /><br />or push_back(), or maybe append()
</p></div></div><p>
+= or +. Don&#39;t use push_back(), string inherits it from vector; this will append data after the trailing 0, which is not what you want.<br />And remember to cast to char so that operator += does what you want (unless you use wide characters, in which case you should use short IIRC).
</p><div class="source-code snippet"><div class="inner"><pre>string s<span class="k2">;</span>
<span class="c">/* ... */</span>
<span class="k1">char</span> c <span class="k3">=</span> <a href="http://www.allegro.cc/manual/readkey" target="_blank"><span class="a">readkey</span></a><span class="k2">(</span><span class="k2">)</span> <span class="k3">&amp;</span> <span class="n">0xFF</span><span class="k2">;</span>
<span class="k1">if</span> <span class="k2">(</span>c <span class="k3">&gt;</span><span class="k3">=</span> <span class="n">32</span><span class="k2">)</span>
  s <span class="k3">+</span><span class="k3">=</span> c<span class="k2">;</span>
</pre></div></div><p>
That&#39;s it. If it crashes, something else is wrong.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Sat, 07 Oct 2006 15:35:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Don&#39;t use push_back(), string inherits it from vector; this will append data after the trailing 0,
</p></div></div><p>
This is wrong (try it!) 
</p><div class="source-code snippet"><div class="inner"><pre><span class="p">#include &lt;string&gt;</span>
<span class="p">#include &lt;iostream&gt;</span>
<span class="k1">using</span> <span class="k1">namespace</span> std<span class="k2">;</span>

<span class="k1">int</span> main<span class="k2">(</span><span class="k2">)</span>
<span class="k2">{</span>
  string s<span class="k2">;</span>
  s.push_back<span class="k2">(</span><span class="s">'X'</span><span class="k2">)</span><span class="k2">;</span>
  s.push_back<span class="k2">(</span><span class="s">'-'</span><span class="k2">)</span><span class="k2">;</span>
  s.push_back<span class="k2">(</span><span class="s">'G'</span><span class="k2">)</span><span class="k2">;</span>
  cout <span class="k3">&lt;</span><span class="k3">&lt;</span> s <span class="k3">&lt;</span><span class="k3">&lt;</span> endl<span class="k2">;</span>
  <span class="k1">return</span> <span class="n">0</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>

</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
in which case you should use short IIRC).
</p></div></div><p>
Use wchar_t (string is a typedef for basic_string&lt;char&gt;, wstring is a typedef for basic_string&lt;wchar_t&gt;).</p><p><a href="http://www.sgi.com/tech/stl/basic_string.html">basic_string info</a></p><p>Pete
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Hull)</author>
		<pubDate>Sat, 07 Oct 2006 20:19:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>std::string does not have a trailing &#39;\0&#39;.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ImLeftFooted)</author>
		<pubDate>Sun, 08 Oct 2006 03:28:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
std::string does not have a trailing &#39;\0&#39;.
</p></div></div><p>
I thought that too, but I checked in the include file <a href="http://www.sgi.com/tech/stl/string">&lt;string&gt;</a> (look at note 3, below). </p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="c">// ------------------------------------------------------------</span></td></tr><tr><td class="number">2</td><td><span class="c">// Class basic_string.  </span></td></tr><tr><td class="number">3</td><td>&#160;</td></tr><tr><td class="number">4</td><td><span class="c">// Class invariants:</span></td></tr><tr><td class="number">5</td><td><span class="c">// (1) [start, finish) is a valid range.</span></td></tr><tr><td class="number">6</td><td><span class="c">// (2) Each iterator in [start, finish) points to a valid object</span></td></tr><tr><td class="number">7</td><td><span class="c">//     of type value_type.</span></td></tr><tr><td class="number">8</td><td><span class="c">// (3) *finish is a valid object of type value_type; in particular,</span></td></tr><tr><td class="number">9</td><td><span class="c">//     it is value_type().</span></td></tr><tr><td class="number">10</td><td><span class="c">// (4) [finish + 1, end_of_storage) is a valid range.</span></td></tr><tr><td class="number">11</td><td><span class="c">// (5) Each iterator in [finish + 1, end_of_storage) points to </span></td></tr><tr><td class="number">12</td><td><span class="c">//     unininitialized memory.</span></td></tr><tr><td class="number">13</td><td>&#160;</td></tr><tr><td class="number">14</td><td><span class="c">// Note one important consequence: a string of length n must manage</span></td></tr><tr><td class="number">15</td><td><span class="c">// a block of memory whose size is at least n + 1.  </span></td></tr></tbody></table></div></div><p>

The relevant part of the standard is <a href="http://www.zib.de/benger/C++/clause21.html#s21.3.4">21.3.4</a>.</p><p>Pete
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Hull)</author>
		<pubDate>Sun, 08 Oct 2006 12:02:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hm, interesting..
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ImLeftFooted)</author>
		<pubDate>Sun, 08 Oct 2006 20:07:39 +0000</pubDate>
	</item>
</rss>
