<?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>GeeksPlanet.net &#187; C++</title>
	<atom:link href="http://geeksplanet.net/category/cpp/feed/" rel="self" type="application/rss+xml" />
	<link>http://geeksplanet.net</link>
	<description>C, C++, JAVA, PERL programming for Dummies</description>
	<lastBuildDate>Wed, 24 Feb 2010 11:38:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>C++ and Java in Online Games</title>
		<link>http://geeksplanet.net/2009/06/cpp/c-and-java-in-online-games/</link>
		<comments>http://geeksplanet.net/2009/06/cpp/c-and-java-in-online-games/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 15:46:12 +0000</pubDate>
		<dc:creator>Satish Gandham</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Internet]]></category>

		<guid isPermaLink="false">http://geeksplanet.net/?p=131</guid>
		<description><![CDATA[There seems to be a new trend in the world of C++ programming with regards to online games. The trend in question is taking an existing game and running it in a browser online. There&#8217;s a lot of open source games that programmers and players will now be able to tap into. The newest generation [...]]]></description>
			<content:encoded><![CDATA[<p>There seems to be a new trend in the world of C++ programming with regards to online games. The trend in question is taking an existing game and running it in a browser online. There&#8217;s a lot of open source games that programmers and players will now be able to tap into. The newest generation of browsers able to do fast JavaScript, Google&#8217;s Chrome for example uses the V8 engine so those games can run pretty quick, this enables users to enjoy a quick and clear gaming experience.</p>
<p>Many games seem to be following this pattern. These Games were originally written in C or C++. With Java these games can easily be converted to be played online.</p>
<p>Remember, we aren&#8217;t talking about light weight game like <a href="http://www.intercasino.co.uk/games/roulette.shtml">online roulette</a> that runs well in all environments. We are referring to games like Quake III, M.U.L.E and FreeCiv some of game history&#8217;s favorites.</p>
<p>Some of these games are JavaScript front end, C server backend so you can even play it on an iPhone 3GS.</p>
]]></content:encoded>
			<wfw:commentRss>http://geeksplanet.net/2009/06/cpp/c-and-java-in-online-games/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>simple Implementation of stack using a linked list</title>
		<link>http://geeksplanet.net/2008/12/data-structures/simple-implementation-of-stack-using-a-linked-list/</link>
		<comments>http://geeksplanet.net/2008/12/data-structures/simple-implementation-of-stack-using-a-linked-list/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 09:13:37 +0000</pubDate>
		<dc:creator>Satish Gandham</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[Single linked list]]></category>
		<category><![CDATA[Stack]]></category>

		<guid isPermaLink="false">http://geeksplanet.net/?p=63</guid>
		<description><![CDATA[Stacks are linear data structures. This means that their contexts are stored in what looks like a line (although vertically). This linear property, however, is not sufficient to discriminate a stack from other linear data structures. For example, an array is a sort of linear data structure in which you can access any element directly. [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Stacks</strong> are linear data structures. This means that their contexts are stored in what looks like a line (although vertically). This linear property, however, is not sufficient to discriminate a stack from other linear data structures. For example, an array is a sort of linear data structure in which you can access any element directly. In contrast, in a stack, you can only access the element at its top. In a stack <em>Last</em> thing <em>In</em> is the <em>First</em> thing <em>Out</em>.  Thus, we say that a stack enforces <strong>LIFO</strong> order.</p>
<p style="text-align: center;"><a href="http://geeksplanet.net/wp-content/uploads/2008/12/stack.gif"><img class="size-full wp-image-72 aligncenter" title="Stacks | Data Structures" src="http://geeksplanet.net/wp-content/uploads/2008/12/stack.gif" alt="" width="500" height="250" /></a></p>
<p>One disadvantage of <a href="http://geeksplanet.net/2008/09/c-programming/implementaion-of-stack-as-an-array-in-c-language/">implementing stack using an array</a> is wastage of space. Most of the times most of the array is left unused. A better way to implement stack is by using a <a href="http://geeksplanet.net/2008/11/data-structures/implementation-of-singly-linked-list-in-c-plus-plus/">linked list</a>. By using a single linked list to implement a stack there is no wastage of space.</p>
<div id="attachment_62" class="wp-caption aligncenter" style="width: 510px"><a href="http://geeksplanet.net/wp-content/uploads/2008/12/linked-list.gif"><img class="size-full wp-image-62" title="linked-list" src="http://geeksplanet.net/wp-content/uploads/2008/12/linked-list.gif" alt="Implementation of stack using a linked list" width="500" height="150" /></a><p class="wp-caption-text">Implementation of stack using a linked list</p></div>
<pre>
<pre class="brush: cpp; title: ; notranslate">
/*
A simple implementation of linked list in C plus plus (CPP/C++)
*/
/*
Compiler used: g++
*/
#include&lt;iostream&gt;
using namespace std;
struct node{
	int data;
	node *next;
	};
//This function pushes data(node) to the stack
node * push(node*,node*);
//This function pops data (node) and returns pointer to the poped node
node * pop(node*);
//This function shows the stack
void show_stack(node*);
///These two global variables will help us track the start and end of the list
node *f,*l;
main()
{
	int i,ch;
	f=l=NULL;
	cout&lt;&lt;&quot;\t 1 to push&quot;&lt;&lt;endl;
	cout&lt;&lt;&quot;\t 2 to pop&quot;&lt;&lt;endl;
	cout&lt;&lt;&quot;\t 3 to show stack&quot;&lt;&lt;endl;
	cout&lt;&lt;&quot;\t 0 to exit&quot;&lt;&lt;endl;
	while(1)
	{
		cout&lt;&lt;&quot;Enter your choice:&quot;;
		cin&gt;&gt;ch;
		switch(ch)
		{
		case 1:
			{
			if(f==NULL)
			l=f=push(f,l);
			else
			l=push(f,l);
			break;
			}
		case 2:
			{
			cout&lt;&lt;&quot;popped:&quot;&lt;&lt;pop(f)-&gt;data&lt;&lt;endl;
			break;
			}

		case 3:
			{
			show_stack(f);
			break;
			}
		case 0:
			break;
		default:
			cout&lt;&lt;&quot;Please enter a proper choice&quot;&lt;&lt;endl;break;
		}
		if(ch==0)
		break;
	}
}
node * push(node *f,node *l)
{
	node *n;
	n=new node;
	cout&lt;&lt;&quot;Enter data:&quot;;
	cin&gt;&gt;n-&gt;data;
	n-&gt;next=NULL;
	if(f==NULL)
	{f=l=n;return f;}
	else
	{
		l-&gt;next=n;
		l=n;return l;
	}

}
void show_stack(node *f)
{
	cout&lt;&lt;&quot;showing data&quot;&lt;&lt;endl;
	node *guest=f;
	while(guest!=NULL)
	{
		cout&lt;&lt;&quot;\t&quot;&lt;&lt;guest-&gt;data&lt;&lt;endl;
		guest=guest-&gt;next;
	}
}
node * pop(node *f)
{
	node *guest,*lb;
	guest=lb=f;
	while(guest-&gt;next!=NULL)
	{
		lb=guest;
		guest=guest-&gt;next;
	}
	lb-&gt;next=NULL;
	l=lb;
	return guest;
}
		</pre>
</pre>
<blockquote><p><strong>Download the program:</strong> <a href="http://geeksplanet.net/wp-content/uploads/2008/12/linked-list-as-a-stack.cpp">Implementation of stack using a single linked list</a></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://geeksplanet.net/2008/12/data-structures/simple-implementation-of-stack-using-a-linked-list/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Implementation of Singly linked list in C plus plus</title>
		<link>http://geeksplanet.net/2008/11/data-structures/implementation-of-singly-linked-list-in-c-plus-plus/</link>
		<comments>http://geeksplanet.net/2008/11/data-structures/implementation-of-singly-linked-list-in-c-plus-plus/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 21:20:48 +0000</pubDate>
		<dc:creator>Satish Gandham</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[Linked List]]></category>

		<guid isPermaLink="false">http://geeksplanet.net/?p=37</guid>
		<description><![CDATA[The simplest kind of linked list is a singly-linked list , which has one link per node. This link points to the next node in the list, or to a null value or empty list if it is the final node.A singly linked list&#8217;s node is divided into two parts. The first part holds or [...]]]></description>
			<content:encoded><![CDATA[<p>The simplest kind of <strong>linked list</strong> is a <strong>singly-linked list </strong>, which has one link per node. This link points to the next node in the list, or to a null value or empty list if it is the final node.A singly linked list&#8217;s node is divided into two parts. The first part holds or points to information about the node, and second part holds the address of next node. A singly linked list travels one way.</p>
<blockquote>
<div id="attachment_38" class="wp-caption aligncenter" style="width: 418px"><a href="http://geeksplanet.net/wp-content/uploads/2008/11/singly-linked-list.png"><img class="size-full wp-image-38" title="singly linked list" src="http://geeksplanet.net/wp-content/uploads/2008/11/singly-linked-list.png" alt="A singly-linked list containing two values: the value of the current node and a link to the next node" width="408" height="41" /></a><p class="wp-caption-text">A singly-linked list containing two values: the value of the current node and a link to the next node</p></div></blockquote>
<pre>
<pre class="brush: cpp; title: ; notranslate">
/*

A simple implementation of linked list in C plus plus (CPP/C++)

*/
/*
Program downloaded from www.GeeksPlanet.net
For any help, post comment here

http://geeksplanet.net/2008/11/data-structures/implementation-of-singly-linked-list-using-c-plus-plus/

Compiler used: g++
*/
#include&lt;iostream&gt;
using namespace std;
struct node{
	int data;
	node *next;
	};
/*
This function adds a node at the end of the
list and returns pointer to the added node,
This takes pointer to the first node and
pointer to the last node as argument. By
giving the last node as argument we are saving
some computer labour as it need not travel
from the start to the end to find the last node
*/
node * addnode(node*,node*);
/*
This function just takes the first node as
the argument and traverses the entire list
displaying the data in each node.
*/
void shownodes(node*);
/*
This function takes the first node as argument
and traverses the list until it finds the last
node and deletes it and returns pointer to the
new last node.
*/
node * delete_node(node*);
/*
*f and *l are the global variables keeping track
of first and last nodes.
*/
node *f,*l;

main()
{
	int i,ch;
	f=l=NULL;
	cout&lt;&lt;&quot;\t 1 to add a node&quot;&lt;&lt;endl;
	cout&lt;&lt;&quot;\t 2 to see the nodes&quot;&lt;&lt;endl;
	cout&lt;&lt;&quot;\t 3 to delete a node&quot;&lt;&lt;endl;
	cout&lt;&lt;&quot;\t 0 to exit&quot;&lt;&lt;endl;
	while(1)
	{
		cout&lt;&lt;&quot;Enter your choice:&quot;;
		cin&gt;&gt;ch;
		switch(ch)
		{
		case 1:
		{
			if(f==NULL)
			l=f=addnode(f,l); //Since first node is the last node
			else
			l=addnode(f,l);	  //Last node is the new node added
			break;
		}
		case 2:
			shownodes(f);break;
		case 3:
			l=delete_node(f);break; // Last node has been changed to the last but one.
		case 0:
			break;
		default:
			cout&lt;&lt;&quot;Please enter a proper choice&quot;&lt;&lt;endl;break;
		}
		if(ch==0)
		break;
	}
}
node * addnode(node *f,node *l)
{
	node *n;
	n=new node;
	//Allocating memory for the new node
	cout&lt;&lt;&quot;Enter data:&quot;;
	cin&gt;&gt;n-&gt;data;
        //This is going to be the last node, so its next point to NULL
	n-&gt;next=NULL;
	//If there is no first node, then the new node is the first and last node.
	if(f==NULL)
	{f=l=n;return f;}
	else
	{
		// Pointing the last node to the new node
		l-&gt;next=n;
		//Setting the new node as the last node
		l=n;return l;
	}

}
void shownodes(node *f)
{
	cout&lt;&lt;&quot;showing data&quot;&lt;&lt;endl;
	node *guest=f;
	while(guest!=NULL)
	{
		cout&lt;&lt;&quot;\t&quot;&lt;&lt;guest-&gt;data&lt;&lt;endl;
		guest=guest-&gt;next;
	}
}
node * delete_node(node *f)
{
	node *guest,*lb;
	guest=lb=f;
	while(guest-&gt;next!=NULL)
	{
		lb=guest;
		guest=guest-&gt;next;
	}
	lb-&gt;next=NULL;
	cout&lt;&lt;&quot;node deleted&quot;&lt;&lt;endl;
	return lb;
}
</pre>
</pre>
<blockquote>
<p style="text-align: center;"><strong>Download the prgoram <a href="http://geeksplanet.net/wp-content/uploads/2008/11/linked-list.cpp">linked-list.cpp</a></strong></p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://geeksplanet.net/2008/11/data-structures/implementation-of-singly-linked-list-in-c-plus-plus/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>A C++ program to generate a Pascal’s triangle</title>
		<link>http://geeksplanet.net/2008/10/cpp/a-c-program-to-generate-a-pascal%e2%80%99s-triangle/</link>
		<comments>http://geeksplanet.net/2008/10/cpp/a-c-program-to-generate-a-pascal%e2%80%99s-triangle/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 10:49:38 +0000</pubDate>
		<dc:creator>Satish Gandham</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Pascals triangle]]></category>

		<guid isPermaLink="false">http://geeksplanet.net/?p=17</guid>
		<description><![CDATA[A C++ program to generate a Pascal’s triangle which is as follows: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 Download the program Pascals-Triangle]]></description>
			<content:encoded><![CDATA[<p>A <strong>C++ program</strong> to generate a <strong>Pascal’s triangle</strong> which is as follows:</p>
<pre>
      1
     1 1
    1 2 1
   1 3 3 1
  1 4 6 4 1</pre>
<pre class="brush: cpp; title: ; notranslate">
&lt;pre&gt;#include&lt;iostream&gt;
using namespace std;
int fact(int);
main()
{
	int rows,i,j,k;
	cout&lt;&lt;&quot;Enter the numbe of rows you want in the triangle:&quot;;
	cin&gt;&gt;rows;
	for(i=0;i&lt;rows;i++)
	{
		//Moving each row by rows-i spaces to get a triangular shape
		for(k=0;k&lt;(rows-i);k++)
		cout&lt;&lt;&quot; &quot;;
		//Loop for printing each row
		for(j=0;j&lt;=i;j++)
		cout&lt;&lt;&quot; &quot;&lt;&lt;fact(i)/(fact(j)*fact(i-j)); //nCr=n!/(r!*(n-r)!)
		cout&lt;&lt;endl;
	}
}

int fact(int i)
{
	int value=1;
	while(i!=0)
	{
		value=value*i;
		i--;
	}
	return value;
}&lt;/pre&gt;
</pre>
<blockquote>
<h2><a href="http://geeksplanet.net/wp-content/uploads/2008/10/pascal-triangle.cpp">Download the program Pascals-Triangle</a></h2>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://geeksplanet.net/2008/10/cpp/a-c-program-to-generate-a-pascal%e2%80%99s-triangle/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

