<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Textprint_ex and strings</title>
		<link>http://www.allegro.cc/forums/view/589884</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 06 Feb 2007 22:12:51 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hey, I&#39;m trying to print a string using textprint_ex, but whenever I get to the line of code that does that, the program crashes. The string itself shows fine in a console window when doing cout.</p><p>The line of code I use, is this:<br />textprintf_ex(buffer, font, 100, y, makecol(255, 255, 255), -1, &quot;%s&quot;, test);</p><p>Anybody knows why it crashes, and how to fix it?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Raf Vermeulen)</author>
		<pubDate>Sun, 04 Feb 2007 05:34:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Let&#39;s see some more code.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kauhiz)</author>
		<pubDate>Sun, 04 Feb 2007 05:39:41 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><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">void</span> load_highscores<span class="k2">(</span><span class="k2">)</span> <span class="k2">{</span></td></tr><tr><td class="number">2</td><td>     <span class="k1">int</span> y <span class="k3">=</span> <span class="n">50</span><span class="k2">;</span></td></tr><tr><td class="number">3</td><td>     string <a href="http://www.allegro.cc/manual/line" target="_blank"><span class="a">line</span></a><span class="k2">;</span></td></tr><tr><td class="number">4</td><td>     string test <span class="k3">=</span> <span class="s">"TEST"</span><span class="k2">;</span></td></tr><tr><td class="number">5</td><td>     ifstream file <span class="k2">(</span><span class="s">"High.txt"</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">6</td><td>     <span class="k1">if</span> <span class="k2">(</span>file.is_open<span class="k2">(</span><span class="k2">)</span><span class="k2">)</span> <span class="k2">{</span></td></tr><tr><td class="number">7</td><td>        <span class="k1">while</span> <span class="k2">(</span><span class="k3">!</span>file.eof<span class="k2">(</span><span class="k2">)</span><span class="k2">)</span><span class="k2">{</span></td></tr><tr><td class="number">8</td><td>              getline <span class="k2">(</span>file,<a href="http://www.allegro.cc/manual/line" target="_blank"><span class="a">line</span></a><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">9</td><td>              cout <span class="k3">&lt;</span><span class="k3">&lt;</span> test <span class="k3">&lt;</span><span class="k3">&lt;</span> <span class="s">"\n"</span><span class="k2">;</span></td></tr><tr><td class="number">10</td><td>              <a href="http://www.allegro.cc/manual/textprintf_ex" target="_blank"><span class="a">textprintf_ex</span></a><span class="k2">(</span>buffer, <a href="http://www.allegro.cc/manual/font" target="_blank"><span class="a">font</span></a>, <span class="n">100</span>, y, <a href="http://www.allegro.cc/manual/makecol" target="_blank"><span class="a">makecol</span></a><span class="k2">(</span><span class="n">255</span>, <span class="n">255</span>, <span class="n">255</span><span class="k2">)</span>, <span class="k3">-</span><span class="n">1</span>, <span class="s">"%s"</span>, test<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">11</td><td>              y <span class="k3">+</span><span class="k3">=</span> <span class="n">20</span><span class="k2">;</span></td></tr><tr><td class="number">12</td><td>        <span class="k2">}</span></td></tr><tr><td class="number">13</td><td>        file.close<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">14</td><td>    <span class="k2">}</span></td></tr><tr><td class="number">15</td><td><span class="k2">}</span></td></tr></tbody></table></div></div><p>

When I comment out the textprintf_ex command, it all works smoothly, but with that command, it crashes.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Raf Vermeulen)</author>
		<pubDate>Sun, 04 Feb 2007 05:41:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That&#39;s because textprintf_ex wants a C-string, not a std::string. I&#39;m surprised that even compiles.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kauhiz)</author>
		<pubDate>Sun, 04 Feb 2007 05:43:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It compiles because variadic functions don&#39;t typecheck &quot;...&quot; arguments.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (X-G)</author>
		<pubDate>Sun, 04 Feb 2007 05:45:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Good to know.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kauhiz)</author>
		<pubDate>Sun, 04 Feb 2007 05:46:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>instead of test use test.c_str()
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HoHo)</author>
		<pubDate>Sun, 04 Feb 2007 05:52:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That works like a charm, the .c_str():D Thanks for the help!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Raf Vermeulen)</author>
		<pubDate>Sun, 04 Feb 2007 05:55:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>.c_str() returns a <tt>char</tt> array (C-style string) just like the <tt>string</tt> you used it on. Just felt the need to point that out. <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kikaru)</author>
		<pubDate>Sun, 04 Feb 2007 06:30:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
It compiles because variadic functions don&#39;t typecheck &quot;...&quot; arguments.
</p></div></div><p>
It does if you add the printf attribute to the function. So either MSVC doesn&#39;t have a way to check it and he&#39;s using MSVC, or he has warnings off. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kitty Cat)</author>
		<pubDate>Sun, 04 Feb 2007 07:42:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Warnings&#39;re turned on. Compiler&#39;s standard one in Dev-C++ (with the Allegro parameter).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Raf Vermeulen)</author>
		<pubDate>Sun, 04 Feb 2007 09:43:29 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Figuring out how to print strings got me so frustrated. I still have no idea where anyone could find out they had to add .c_str() to their string variable. I&#39;m just glad someone on the forums knew.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Black)</author>
		<pubDate>Tue, 06 Feb 2007 21:00:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Possumdude0 said:</div><div class="quote"><p>

I still have no idea where anyone could find out they had to add .c_str() to their string variable.
</p></div></div><p> Google is your friend. Or your favorite porn search engine .
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (GullRaDriel)</author>
		<pubDate>Tue, 06 Feb 2007 21:26:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>GullRaDriel: wow, you&#39;ve answered almost every one of my posts today!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Black)</author>
		<pubDate>Tue, 06 Feb 2007 21:33:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I still have no idea where anyone could find out they had to add .c_str() to their string variable.
</p></div></div><p>
From wherever you were supposed to have learned C++.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (gnolam)</author>
		<pubDate>Tue, 06 Feb 2007 21:38:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I learned C++ from gamedev.net, and a little right here.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Black)</author>
		<pubDate>Tue, 06 Feb 2007 21:42:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Get a <a href="http://www.google.com/search?hl=et&amp;ie=UTF-8&amp;oe=UTF-8&amp;q=good+free+c%2B%2B+book&amp;btnG=Otsi&amp;lr=">good free C++ book</a>. I learnt about .c_str() from the one that should be on the first link, &quot;thinking in C++&quot; by Bruce Eckel.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HoHo)</author>
		<pubDate>Tue, 06 Feb 2007 21:52:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Possumdude0: It&#39;s because I got nothing else to do today.</p><p>I second HoHo and Gnolam thought.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (GullRaDriel)</author>
		<pubDate>Tue, 06 Feb 2007 22:12:51 +0000</pubDate>
	</item>
</rss>
