<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
	>
<channel>
	<title>Comments for MN Scout's Weblog</title>
	<atom:link href="http://mnscout.com/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://mnscout.com</link>
	<description>Programming to cooking to the great outdoors.</description>
	<pubDate>Thu, 04 Dec 2008 00:23:55 +0000</pubDate>
	<generator>http://wordpress.org/?v=MU</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>Comment on 2 Dimensional Array Dynamic Allocation in C by Aron Koszo</title>
		<link>http://mnscout.com/2008/02/14/2-dimensional-array-dynamic-allocation-in-c/#comment-74</link>
		<dc:creator>Aron Koszo</dc:creator>
		<pubDate>Mon, 01 Dec 2008 21:08:48 +0000</pubDate>
		<guid isPermaLink="false">http://mnscout.wordpress.com/?p=22#comment-74</guid>
		<description>Thank you, it helped me a lot...
I forgot how we did this in class but I think we used 2 or 3 pointers, so it was all complicated and of course later I didn't remember it. Luckily I found this article and with some modifications it will just be fine :) Using method 2, now I can easily do the dynamic memory allocation and later I can use the array just like a static 2 dimensional array.</description>
		<content:encoded><![CDATA[<p>Thank you, it helped me a lot&#8230;<br />
I forgot how we did this in class but I think we used 2 or 3 pointers, so it was all complicated and of course later I didn&#8217;t remember it. Luckily I found this article and with some modifications it will just be fine <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> Using method 2, now I can easily do the dynamic memory allocation and later I can use the array just like a static 2 dimensional array.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on 2 Dimensional Array Dynamic Allocation in C by Irfan Ahmed</title>
		<link>http://mnscout.com/2008/02/14/2-dimensional-array-dynamic-allocation-in-c/#comment-72</link>
		<dc:creator>Irfan Ahmed</dc:creator>
		<pubDate>Wed, 19 Nov 2008 02:35:39 +0000</pubDate>
		<guid isPermaLink="false">http://mnscout.wordpress.com/?p=22#comment-72</guid>
		<description>Thanks a lot, just the right code I was looking for. Really appreciate your effort.</description>
		<content:encoded><![CDATA[<p>Thanks a lot, just the right code I was looking for. Really appreciate your effort.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on 2 Dimensional Array Dynamic Allocation in C by Heinz van Saanen</title>
		<link>http://mnscout.com/2008/02/14/2-dimensional-array-dynamic-allocation-in-c/#comment-69</link>
		<dc:creator>Heinz van Saanen</dc:creator>
		<pubDate>Thu, 04 Sep 2008 08:04:45 +0000</pubDate>
		<guid isPermaLink="false">http://mnscout.wordpress.com/?p=22#comment-69</guid>
		<description>Very nice overview, as others said! But  somehow erroneous and uncomplete according to Ansii-C. I guess thats may be some Windows-illness. So my suggestion, which even will compile and run on coffee-machines, as far those have implemented a true  Ansii-C compiler:-)

/**
 ** This is an example program that I wrote when learning about how
 ** to make dynamically allocated 2 dimmensional arrays in c.
 ** I looked at a bunch of websites, but the best site that I
 ** found that actually showed and explained the
 ** different methods was http://www.lysator.liu.se/c/c-faq/c-2.html
 **
 ** (c) 2008 Adam J Bavier all rights reserved
*/


/** Includes */
#include 
#include 


/** Usage: exe foo-rows foo-columns */
int main( int argc, char** argv) {

	int i, j, nrows, ncolumns;
	int *array1, **array2, **array3;

	/** Get the number of rows and columns and make some basic checks */
	if(argc != 3) {
		printf("Usage: exe foo-rows foo-columns\n");
		return 1;
	}
	nrows = atoi(argv[1]);
	ncolumns = atoi(argv[2]);

	if(nrows&#60;0 &#124;&#124; ncolumns&#60;0) {
		printf("foo-rows and foo-columns must be positive\n");
		return 1;
	}
	if(!nrows &#124;&#124; !ncolumns) {
		printf("foo-rows and foo-columns must be bigger then 1\n");
		return 1;
	}

	/** Method 1:
	 ** Simulate a two dimmensional array with a single,
	 ** dynamically-allocated one-dimensional array
	 ** Note subscript calculations must be performed by you.
	 ** i row, j column is array1[i*ncolumns+j] not array1[i][j] */
	array1 = (int *) malloc(nrows * ncolumns * sizeof(int));
	if(array1 == NULL) {
		printf("array 1: Out of memory\n");
		return 1;
	}

	/** Method 2:
	 ** Allocate an array of pointers.
	 ** Then initialize each pointer to a dynamically
	 ** allocated row. */
	array2 = (int **) malloc(nrows * sizeof(int*));
	if(array2 == NULL) {
		printf("array2: Out of memory\n");
		return 1;
	}

	for(i=0; i&#60;nrows; i++)
        array2[i] = (int *) malloc(ncolumns * sizeof(int));

	/** Method 3;
	 ** Using explicit pointer arithmetic
	 ** the array's contents can be kept contiguous */
	array3 = (int **) malloc(nrows * sizeof(int *));
	if(array3 == NULL) {
		printf("array3: Out of memory\n");
		return 1;
	}

	array3[0] = (int *) malloc(nrows * ncolumns * sizeof(int));
	if(array3 == NULL) {
		printf("array3: Out of memory\n");
		return 1;
	}

	for(i=1; i&#60;nrows; i++)
		array3[i] = array3[0] + i*ncolumns;

	/** Put some random values into array1 */
	srand(100);
	for(i=0; i&#60;nrows; i++)
        for(j=0; j&#60;ncolumns; j++)
			array1[i*ncolumns+j] = rand();

	/** Put the same values into array2 */
	srand(100);
	for(i=0; i&#60;nrows; i++)
		for(j=0; j&#60;ncolumns; j++)
			array2[i][j] = rand();

	/** Put the same values into array3 */
	srand(100);
	for(i=0; i&#60;nrows; i++)
		for(j=0; j&#60;ncolumns; j++)
			array3[i][j] = rand();

	/** Print array1 */
	printf("array1:\n");
	for (i=0; i&#60;nrows; i++) {
		printf("\n");
			for (j=0; j&#60;ncolumns; j++){
				printf("%15d ", array1[i*ncolumns+j]);
			}
	}
	printf("\n\n");

	/** Print array2 */
	printf("array2:\n");
	for(i=0; i&#60;nrows; i++) {
		printf("\n");
		for (j=0; j&#60;ncolumns; j++)
			printf("%15d ", array2[i][j]);
	}
	printf("\n\n");

	/** Print array3 */
	printf("array3:\n");
	for(i=0; i&#60;nrows; i++) {
		printf("\n");
		for(j=0; j&#60;ncolumns; j++)
			printf("%15d ", array3[i][j]);
	}
	printf("\n\n");

	/** Free memory */
	printf("Free array1 in total\n\n");
	free(array1);

	/** Iterate through array2 and array3 and free the rows */
	printf("Free array2 rows first\n");
	for(i=0;i&#60;nrows;i++)
		free(array2[i]);

	printf("Free array3 rows first\n");
	free(array3[0]);
	printf("\n");

	/** Then free the array of pointers */
	printf("Free array of pointers array2 then\n");
	free(array2);

	printf("Free array of pointers array3 then\n");
	free(array3);

	printf("\nDone.\n");

	return 0;
}</description>
		<content:encoded><![CDATA[<p>Very nice overview, as others said! But  somehow erroneous and uncomplete according to Ansii-C. I guess thats may be some Windows-illness. So my suggestion, which even will compile and run on coffee-machines, as far those have implemented a true  Ansii-C compiler:-)</p>
<p>/**<br />
 ** This is an example program that I wrote when learning about how<br />
 ** to make dynamically allocated 2 dimmensional arrays in c.<br />
 ** I looked at a bunch of websites, but the best site that I<br />
 ** found that actually showed and explained the<br />
 ** different methods was <a href="http://www.lysator.liu.se/c/c-faq/c-2.html" rel="nofollow">http://www.lysator.liu.se/c/c-faq/c-2.html</a><br />
 **<br />
 ** (c) 2008 Adam J Bavier all rights reserved<br />
*/</p>
<p>/** Includes */<br />
#include<br />
#include </p>
<p>/** Usage: exe foo-rows foo-columns */<br />
int main( int argc, char** argv) {</p>
<p>	int i, j, nrows, ncolumns;<br />
	int *array1, **array2, **array3;</p>
<p>	/** Get the number of rows and columns and make some basic checks */<br />
	if(argc != 3) {<br />
		printf(&#8221;Usage: exe foo-rows foo-columns\n&#8221;);<br />
		return 1;<br />
	}<br />
	nrows = atoi(argv[1]);<br />
	ncolumns = atoi(argv[2]);</p>
<p>	if(nrows&lt;0 || ncolumns&lt;0) {<br />
		printf(&#8221;foo-rows and foo-columns must be positive\n&#8221;);<br />
		return 1;<br />
	}<br />
	if(!nrows || !ncolumns) {<br />
		printf(&#8221;foo-rows and foo-columns must be bigger then 1\n&#8221;);<br />
		return 1;<br />
	}</p>
<p>	/** Method 1:<br />
	 ** Simulate a two dimmensional array with a single,<br />
	 ** dynamically-allocated one-dimensional array<br />
	 ** Note subscript calculations must be performed by you.<br />
	 ** i row, j column is array1[i*ncolumns+j] not array1[i][j] */<br />
	array1 = (int *) malloc(nrows * ncolumns * sizeof(int));<br />
	if(array1 == NULL) {<br />
		printf(&#8221;array 1: Out of memory\n&#8221;);<br />
		return 1;<br />
	}</p>
<p>	/** Method 2:<br />
	 ** Allocate an array of pointers.<br />
	 ** Then initialize each pointer to a dynamically<br />
	 ** allocated row. */<br />
	array2 = (int **) malloc(nrows * sizeof(int*));<br />
	if(array2 == NULL) {<br />
		printf(&#8221;array2: Out of memory\n&#8221;);<br />
		return 1;<br />
	}</p>
<p>	for(i=0; i&lt;nrows; i++)<br />
        array2[i] = (int *) malloc(ncolumns * sizeof(int));</p>
<p>	/** Method 3;<br />
	 ** Using explicit pointer arithmetic<br />
	 ** the array&#8217;s contents can be kept contiguous */<br />
	array3 = (int **) malloc(nrows * sizeof(int *));<br />
	if(array3 == NULL) {<br />
		printf(&#8221;array3: Out of memory\n&#8221;);<br />
		return 1;<br />
	}</p>
<p>	array3[0] = (int *) malloc(nrows * ncolumns * sizeof(int));<br />
	if(array3 == NULL) {<br />
		printf(&#8221;array3: Out of memory\n&#8221;);<br />
		return 1;<br />
	}</p>
<p>	for(i=1; i&lt;nrows; i++)<br />
		array3[i] = array3[0] + i*ncolumns;</p>
<p>	/** Put some random values into array1 */<br />
	srand(100);<br />
	for(i=0; i&lt;nrows; i++)<br />
        for(j=0; j&lt;ncolumns; j++)<br />
			array1[i*ncolumns+j] = rand();</p>
<p>	/** Put the same values into array2 */<br />
	srand(100);<br />
	for(i=0; i&lt;nrows; i++)<br />
		for(j=0; j&lt;ncolumns; j++)<br />
			array2[i][j] = rand();</p>
<p>	/** Put the same values into array3 */<br />
	srand(100);<br />
	for(i=0; i&lt;nrows; i++)<br />
		for(j=0; j&lt;ncolumns; j++)<br />
			array3[i][j] = rand();</p>
<p>	/** Print array1 */<br />
	printf(&#8221;array1:\n&#8221;);<br />
	for (i=0; i&lt;nrows; i++) {<br />
		printf(&#8221;\n&#8221;);<br />
			for (j=0; j&lt;ncolumns; j++){<br />
				printf(&#8221;%15d &#8220;, array1[i*ncolumns+j]);<br />
			}<br />
	}<br />
	printf(&#8221;\n\n&#8221;);</p>
<p>	/** Print array2 */<br />
	printf(&#8221;array2:\n&#8221;);<br />
	for(i=0; i&lt;nrows; i++) {<br />
		printf(&#8221;\n&#8221;);<br />
		for (j=0; j&lt;ncolumns; j++)<br />
			printf(&#8221;%15d &#8220;, array2[i][j]);<br />
	}<br />
	printf(&#8221;\n\n&#8221;);</p>
<p>	/** Print array3 */<br />
	printf(&#8221;array3:\n&#8221;);<br />
	for(i=0; i&lt;nrows; i++) {<br />
		printf(&#8221;\n&#8221;);<br />
		for(j=0; j&lt;ncolumns; j++)<br />
			printf(&#8221;%15d &#8220;, array3[i][j]);<br />
	}<br />
	printf(&#8221;\n\n&#8221;);</p>
<p>	/** Free memory */<br />
	printf(&#8221;Free array1 in total\n\n&#8221;);<br />
	free(array1);</p>
<p>	/** Iterate through array2 and array3 and free the rows */<br />
	printf(&#8221;Free array2 rows first\n&#8221;);<br />
	for(i=0;i&lt;nrows;i++)<br />
		free(array2[i]);</p>
<p>	printf(&#8221;Free array3 rows first\n&#8221;);<br />
	free(array3[0]);<br />
	printf(&#8221;\n&#8221;);</p>
<p>	/** Then free the array of pointers */<br />
	printf(&#8221;Free array of pointers array2 then\n&#8221;);<br />
	free(array2);</p>
<p>	printf(&#8221;Free array of pointers array3 then\n&#8221;);<br />
	free(array3);</p>
<p>	printf(&#8221;\nDone.\n&#8221;);</p>
<p>	return 0;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on 2 Dimensional Array Dynamic Allocation in C by ranjit</title>
		<link>http://mnscout.com/2008/02/14/2-dimensional-array-dynamic-allocation-in-c/#comment-68</link>
		<dc:creator>ranjit</dc:creator>
		<pubDate>Sun, 24 Aug 2008 12:09:11 +0000</pubDate>
		<guid isPermaLink="false">http://mnscout.wordpress.com/?p=22#comment-68</guid>
		<description>awesome..
its cauze of guys like u that we are able to perform our task..
thanks..</description>
		<content:encoded><![CDATA[<p>awesome..<br />
its cauze of guys like u that we are able to perform our task..<br />
thanks..</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Solar Powered Rotating Plant Stand by Conner</title>
		<link>http://mnscout.com/2008/05/05/solar-powered-rotating-plant-stand/#comment-67</link>
		<dc:creator>Conner</dc:creator>
		<pubDate>Fri, 18 Jul 2008 14:00:13 +0000</pubDate>
		<guid isPermaLink="false">http://mnscout.wordpress.com/?p=65#comment-67</guid>
		<description>Adam, 

That is a great idea for a really common problem.  I hate it when my plants lean into the sun, it's hard enough for me to remember to water them, let alone turn them occasionally to prevent this.  A great simple and elegant solution.</description>
		<content:encoded><![CDATA[<p>Adam, </p>
<p>That is a great idea for a really common problem.  I hate it when my plants lean into the sun, it&#8217;s hard enough for me to remember to water them, let alone turn them occasionally to prevent this.  A great simple and elegant solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Whole Wheat Bread Recipe by mnscout</title>
		<link>http://mnscout.com/2007/11/16/whole-wheat-bread-recipe/#comment-66</link>
		<dc:creator>mnscout</dc:creator>
		<pubDate>Wed, 18 Jun 2008 19:52:47 +0000</pubDate>
		<guid isPermaLink="false">http://mnscout.wordpress.com/2007/11/16/whole-wheat-bread-recipe/#comment-66</guid>
		<description>Thank you for the comment.  I did knead the dough, unfortunately I did not take a picture of the process.  Unlike my other recipe directions, these pictures are not meant to chronicle the entire process.  I would also highly recommend rolling the dough up before putting it in the bread pan like I show in my white bread recipe -- I should have done this with this recipe also.</description>
		<content:encoded><![CDATA[<p>Thank you for the comment.  I did knead the dough, unfortunately I did not take a picture of the process.  Unlike my other recipe directions, these pictures are not meant to chronicle the entire process.  I would also highly recommend rolling the dough up before putting it in the bread pan like I show in my white bread recipe &#8212; I should have done this with this recipe also.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Whole Wheat Bread Recipe by NORAH</title>
		<link>http://mnscout.com/2007/11/16/whole-wheat-bread-recipe/#comment-65</link>
		<dc:creator>NORAH</dc:creator>
		<pubDate>Wed, 18 Jun 2008 19:45:42 +0000</pubDate>
		<guid isPermaLink="false">http://mnscout.wordpress.com/2007/11/16/whole-wheat-bread-recipe/#comment-65</guid>
		<description>you didn't knead this bread at all?</description>
		<content:encoded><![CDATA[<p>you didn&#8217;t knead this bread at all?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Solar Powered Rotating Plant Stand by David Stone</title>
		<link>http://mnscout.com/2008/05/05/solar-powered-rotating-plant-stand/#comment-64</link>
		<dc:creator>David Stone</dc:creator>
		<pubDate>Tue, 27 May 2008 00:54:03 +0000</pubDate>
		<guid isPermaLink="false">http://mnscout.wordpress.com/?p=65#comment-64</guid>
		<description>Hi Adam, thats really awesome, I see what you mean when you say that you got a lot of k-enex (I know I spelled that wrong). I like the gear ratios. 

David</description>
		<content:encoded><![CDATA[<p>Hi Adam, thats really awesome, I see what you mean when you say that you got a lot of k-enex (I know I spelled that wrong). I like the gear ratios. </p>
<p>David</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on 2 Dimensional Array Dynamic Allocation in C by mighty</title>
		<link>http://mnscout.com/2008/02/14/2-dimensional-array-dynamic-allocation-in-c/#comment-60</link>
		<dc:creator>mighty</dc:creator>
		<pubDate>Sat, 26 Apr 2008 10:50:34 +0000</pubDate>
		<guid isPermaLink="false">http://mnscout.wordpress.com/?p=22#comment-60</guid>
		<description>same here, nice simple and to the point. cheers.</description>
		<content:encoded><![CDATA[<p>same here, nice simple and to the point. cheers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Java Text Converter - Text to Cambridge Format by mnscout</title>
		<link>http://mnscout.com/2007/11/09/11/#comment-59</link>
		<dc:creator>mnscout</dc:creator>
		<pubDate>Mon, 21 Apr 2008 23:37:15 +0000</pubDate>
		<guid isPermaLink="false">http://mnscout.wordpress.com/2007/11/09/11/#comment-59</guid>
		<description>I wlil post up and aslo send you a visroen taht you can run on your own cpmtoeur this wkneeed.  I've been mnaenig to cnaghe sthniemog with tihs aiaopciltpn, so it'll mkae me do it.</description>
		<content:encoded><![CDATA[<p>I wlil post up and aslo send you a visroen taht you can run on your own cpmtoeur this wkneeed.  I&#8217;ve been mnaenig to cnaghe sthniemog with tihs aiaopciltpn, so it&#8217;ll mkae me do it.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
