<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>jBoxer &#187; c</title>
	<atom:link href="http://jboxer.com/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://jboxer.com</link>
	<description>I change the directions of small pieces of metal for a living.</description>
	<lastBuildDate>Wed, 28 Jul 2010 14:23:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Using C, convert a dynamically-allocated int array to a comma-separated string as cleanly as possible</title>
		<link>http://jboxer.com/2009/11/using-c-convert-a-dynamic-int-array-to-a-comma-separated-string-as-cleanly-as-possible/</link>
		<comments>http://jboxer.com/2009/11/using-c-convert-a-dynamic-int-array-to-a-comma-separated-string-as-cleanly-as-possible/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 21:11:37 +0000</pubDate>
		<dc:creator>Jake Boxer</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[cisco]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://jboxer.com/?p=248</guid>
		<description><![CDATA[EDIT: There are no &#8220;dynamic arrays&#8221;, so to speak, in C. What I meant was &#8220;dynamically-allocated&#8221;. I&#8217;ve updated the wording to reflect this. EDIT 2: Someone on Reddit pointed out that my Python example doesn&#8217;t actually work, since I have an array of ints rather than strings. I&#8217;ve updated the code example so it works. [...]]]></description>
			<content:encoded><![CDATA[<p><strong>EDIT: There are no &#8220;dynamic arrays&#8221;, so to speak, in C. What I meant was &#8220;dynamically-allocated&#8221;. I&#8217;ve updated the wording to reflect this.</strong></p>
<p><strong>EDIT 2: Someone on <a href="http://www.reddit.com/r/programming/comments/a50gy/using_c_convert_a_dynamic_int_array_to_a/">Reddit</a> pointed out that my Python example doesn&#8217;t actually work, since I have an array of ints rather than strings. I&#8217;ve updated the code example so it works.</strong></p>
<p>I&#8217;m much less experienced in C than I am in higher-level languages. At Cisco, we use C, and I sometimes run into something that would be easy to do in Java or Python, but very difficult to do in C. Now is one of those times.</p>
<p>I have a dynamically-allocated array of unsigned integers which I need to convert to a comma-separated string for logging. While the integers are not likely to be very large, they could conceptually be anywhere from 0 to 4,294,967,295 In Python, that&#8217;s one short line.</p>
<pre class="brush: python;">my_str = ','.join([str(num) for num in my_list])</pre>
<p>How elegantly can people do this in C? I came up with a way, but it&#8217;s gross. If anyone knows a nice way to do it, please enlighten me.</p>
]]></content:encoded>
			<wfw:commentRss>http://jboxer.com/2009/11/using-c-convert-a-dynamic-int-array-to-a-comma-separated-string-as-cleanly-as-possible/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>
