<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Drawing text from variables?</title>
		<link>http://www.allegro.cc/forums/view/608396</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Wed, 21 Sep 2011 19:43:39 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I understand the basics of allegro 5&#39;s draw text routines, but was wondering if it&#39;s possible to use text variables when using the routines?</p><p>example, I&#39;m hoping to do something similar to this:</p><p>string answer = &quot;blahblah&quot;;</p><p>al_draw_textf(font18, al_map_rgb(255, 255, 255), WIDTH / 2, HEIGHT / 2, ALLEGRO_ALIGN_CENTRE, &quot;The answer is: %?&quot;, answer);</p><p>Any help is greatly appreciated
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (curious_newbie)</author>
		<pubDate>Tue, 20 Sep 2011 12:32:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>In &#39;C&#39; I use &quot;strcpy&quot;, &quot;strcat&quot;, and &quot;itoa&quot; on a char[] (in &#39;C&#39; a string variable is an array of char) variable, which I pass to the text display function.<br />It might be a place to start, though there are other seemingly funkier ways to do it with other languages e.g. C++.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Yodhe23)</author>
		<pubDate>Tue, 20 Sep 2011 12:44:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m not sure whether or not allegro supports it, but if not then you could wrap al_draw_textf in a function that does by using sprintf (for string formatting), and va_list (for a variable number of arguments to your new function).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (james_lohr)</author>
		<pubDate>Tue, 20 Sep 2011 12:49:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Just use <span class="source-code">answer.c_str<span class="k2">(</span><span class="k2">)</span></span> Generates a null-terminated sequence of characters (c-string) with the same content as the string object and returns it as a pointer to an array of characters.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (AMCerasoli)</author>
		<pubDate>Tue, 20 Sep 2011 12:49:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The answer.c_str() did exactly what I was looking for, thank you all for the replies
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (curious_newbie)</author>
		<pubDate>Tue, 20 Sep 2011 12:51:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/608396/931632#target">Yodhe23</a> said:</div><div class="quote"><p>n &#39;C&#39; I use &quot;strcpy&quot;, &quot;strcat&quot;, and &quot;itoa&quot; on a char[]</p></div></div><p>
itoa is non-standard. For standard, use sprintf (on an extra buffer).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (weapon_S)</author>
		<pubDate>Tue, 20 Sep 2011 20:40:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks for the heads-up about &quot;itoa&quot; and &quot;sprintf&quot;, have duly changed my code and coding habits.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Yodhe23)</author>
		<pubDate>Wed, 21 Sep 2011 19:43:39 +0000</pubDate>
	</item>
</rss>
