<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>aramonkg101's Feed - Programmer's Heaven</title>
    <link>http://www.programmersheaven.com/feed/User/331561/RSS.aspx</link>
    <description>Events at Programmer's Heaven related to the user aramonkg101.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Sun, 19 May 2013 23:39:58 -0700</pubDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <item>
      <title>Re: Timed Input</title>
      <link />
      <description>&lt;p&gt;Posted a 'reply on the C and C++ forum.&lt;/p&gt;What device are we talking about? Do you have any documentation on the hardware(registers, memory, controller) or are you going to build it yourself? Connection? USB, serial, wireless? What Operating System are you going to work with? These are just a few questions to start with.&lt;br /&gt;</description>
      <pubDate>Sun, 18 Jan 2009 04:55:17 -0700</pubDate>
    </item>
    <item>
      <title>Re: linked stack problem with repeated output</title>
      <link />
      <description>&lt;p&gt;Posted a 'reply on the Visual C++ forum.&lt;/p&gt;Well, that you get no errors during compilation means that the syntax and grammar of the code violates no rules. It does not mean that the logic/design of the program is correct. &lt;br /&gt;
&lt;br /&gt;
Also you have to decide in which language you are going to write the program in. Using malloc(), no classes but employing cin and cout is going to confuse you in the long run.&lt;br /&gt;
&lt;br /&gt;
Finally not freeing up memory you use through malloc is bad practice and will only lead to problems.&lt;br /&gt;
&lt;br /&gt;
The problem of repeated output is found somewhere here&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
      temp=(struct node *)malloc(sizeof(struct node));
      cout &amp;lt;&amp;lt; "Enter a node data :";
      cin &amp;gt;&amp;gt; data;
      temp-&amp;gt;data=data;
      temp-&amp;gt;link=top;
      top=temp;    
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
You always use struct node* top to save your values and you overwrite it. The problem is that with the structure of your program there is no easy way out of it. A corrected version of the code based on your approach is like this.&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;

struct node {    
  int data;
  struct node *link;
};

int main(int argc, char** argv){
  int choice, data;
  struct node base, *temp;

  base.link = NULL;

  /* Infinite loop is used to insert/delete infinite number of nodes */
  while(1) {
    printf("\n1.Push\n2.Pop\n3.Display\n4.Exit\n");
    printf("\nEnter ur choice:");        
    scanf("%d", &amp;amp;choice);
    
    switch(choice) {
    case 1:
      temp = &amp;amp;base;
      /* Find the last entry */
      while(temp-&amp;gt;link != NULL)
	temp = temp-&amp;gt;link;
      /* Allocate memory for the new entry */
      temp-&amp;gt;link = (struct node *)malloc(sizeof(struct node));
      printf("Enter a node data :");
      scanf("%d", &amp;amp;data);
      /* The data is inserted in the new entry. NULL is set 
	 to show that this is the new last entry */
      temp-&amp;gt;link-&amp;gt;data = data;
      temp-&amp;gt;link-&amp;gt;link = NULL;
      break;   
    case 2:
      if(base.link == NULL){   
        printf("\nStack Underflow\n");
      }
      else{
	temp = &amp;amp;base;
	/* Finds the last entry but allows to free up memory too */
	while(temp-&amp;gt;link-&amp;gt;link != NULL)
	  temp = temp-&amp;gt;link;
	printf("The poped element is %d", temp-&amp;gt;link-&amp;gt;data);
	free(temp-&amp;gt;link);
	/* There is no data at temp-&amp;gt;link anymore
	   so we set it to NULL */
	temp-&amp;gt;link = NULL;
      }
      break;   
    case 3: 
      if(base.link == NULL){
        printf("\nStack is empty\n");
      }
      else{
	temp = base.link;
	/* Find and display all but last entry */
	while(temp-&amp;gt;link != NULL) {
	  printf("-&amp;gt;%d", temp-&amp;gt;data); 
	  temp = temp-&amp;gt;link;
	}
	printf("-&amp;gt;%d", temp-&amp;gt;data);
      }   
      break; 
    case 4:
      /* Free up memory used by malloc() calls */
      while(base.link != NULL){
	temp = &amp;amp;base;
	while(temp-&amp;gt;link-&amp;gt;link != NULL)
	  temp = temp-&amp;gt;link;
	free(temp-&amp;gt;link);
	temp-&amp;gt;link = NULL;
      }
      exit(0);
    }           
  }  
  
  return 0;
}
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
To better design your stack take a look at this&lt;br /&gt;
&lt;a href="http://www.cs.bu.edu/teaching/c/stack/linked-list/"&gt;http://www.cs.bu.edu/teaching/c/stack/linked-list/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
If you want to use C++ consider classes.</description>
      <pubDate>Sat, 10 Jan 2009 09:51:56 -0700</pubDate>
    </item>
    <item>
      <title>Re: Timed Input</title>
      <link />
      <description>&lt;p&gt;Posted a 'reply on the C and C++ forum.&lt;/p&gt;Well, C++ does not provide the facilities you ask "out of the box". You could code it yourself if you had good knowledge of C++, perhaps some knowledge of assembly, some knowledge of operating system design and in-depth knowledge of the hardware of that device. Since you say you are a novice you probably do not have that.&lt;br /&gt;
&lt;br /&gt;
So what you could do is use a library of classes/methods(C++) or functions(C) that will allow you to "communicate" with the device through a C++ program. Of course that is only possible if such a library exists and is available.&lt;br /&gt;
&lt;br /&gt;
Alternatively you could use your own operating system's functionatily exposed to you through a set of functions found in your OS developer documentation. These set of functions, also called API, will provide you some control of the device but depending on the device what you can do may be limited.</description>
      <pubDate>Sat, 10 Jan 2009 05:08:33 -0700</pubDate>
    </item>
    <item>
      <title>Re: i have a doubt about malloc function</title>
      <link />
      <description>&lt;p&gt;Posted a 'reply on the C and C++ forum.&lt;/p&gt;You can access the byte at pointer+1 but the result of modifying it is &lt;strong&gt;undefined&lt;/strong&gt;, which means that you may corrupt some other data structure, pointer or whatever else is at that address on the heap segment of memory.&lt;br /&gt;
&lt;br /&gt;
What you can safely access and change is &lt;strong&gt;only&lt;/strong&gt; the byte(s) malloc gives you.</description>
      <pubDate>Thu, 08 Jan 2009 16:50:12 -0700</pubDate>
    </item>
    <item>
      <title>Re: Pointer to Char Problem</title>
      <link />
      <description>&lt;p&gt;Posted a 'reply on the C and C++ forum.&lt;/p&gt;True that! Mae culpa. Which makes the code look something like this in the non-string class program.&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
 #include &amp;lt;iostream&amp;gt;
 using namespace std;
 
 int main()
 {
&lt;span style="color: Red;"&gt;-  char *name = (char*) malloc(20);&lt;/span&gt;
&lt;span style="color: Green;"&gt;+  char *name = (char*) new char[20];&lt;/span&gt;
   cout &amp;lt;&amp;lt; " Enter your name with space(E.g Joe Mark)\n";
   cin.getline(name, 20);
   cout &amp;lt;&amp;lt; name;
&lt;span style="color: Red;"&gt;-  free(name);&lt;/span&gt;
&lt;span style="color: Green;"&gt;+  delete [] name;&lt;/span&gt;
   system("pause");
   return 0;
}
&lt;/pre&gt;&lt;br /&gt;</description>
      <pubDate>Thu, 08 Jan 2009 15:52:54 -0700</pubDate>
    </item>
    <item>
      <title>Re: Print all possible combination of 4 digit numbers</title>
      <link />
      <description>&lt;p&gt;Posted a 'reply on the C and C++ forum.&lt;/p&gt;Well, not using language facilities will make your life only harder. Also if you want to change the number of digits that will be printed you will need to modify the code and add/remove nested loops. &lt;br /&gt;
&lt;br /&gt;
To the point... You can use nested loops to find all the possible ways these four digits can be ordered (duplicate digits allowed) and then remove those in which a digit is found more than once. So that you get your permutations. It is a blunt solution, but it works. The code could be something like this for the case of 1,2,3 and 4.&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
#include &amp;lt;stdio.h&amp;gt;

int main(int argc, char** argv){
  int a,b,c,d;

  for(a=1; a&amp;lt;5; a++){
    for(b=1; b&amp;lt;5; b++){
      for(c=1; c&amp;lt;5; c++){
	for(d=1; d&amp;lt;5; d++){
	  if(!(a==b || a==c || a==d || b==c || b==d || c==d))
	    printf("%d%d%d%d\n",a,b,c,d);
	}
      }
    }
  }

  return 0;
}
&lt;/pre&gt;</description>
      <pubDate>Tue, 06 Jan 2009 13:50:05 -0700</pubDate>
    </item>
    <item>
      <title>Re: Compact Disc Writing in C programming</title>
      <link />
      <description>&lt;p&gt;Posted a 'reply on the LINUX programming forum.&lt;/p&gt;&lt;a href="http://www.cdrkit.org/"&gt;http://www.cdrkit.org/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Source code included :)&lt;br /&gt;</description>
      <pubDate>Tue, 06 Jan 2009 08:32:08 -0700</pubDate>
    </item>
    <item>
      <title>Re: mutex and threads</title>
      <link />
      <description>&lt;p&gt;Posted a 'reply on the LINUX programming forum.&lt;/p&gt;You could try this&lt;br /&gt;
&lt;br /&gt;
&lt;a href="https://computing.llnl.gov/tutorials/pthreads/"&gt;https://computing.llnl.gov/tutorials/pthreads/&lt;/a&gt;&lt;br /&gt;</description>
      <pubDate>Tue, 06 Jan 2009 08:28:00 -0700</pubDate>
    </item>
    <item>
      <title>Re: C Multithreading/MultiTasking</title>
      <link />
      <description>&lt;p&gt;Posted a 'reply on the C and C++ forum.&lt;/p&gt;A detailed tutorial on POSIX Threads Programming for use with C language can be found here.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="https://computing.llnl.gov/tutorials/pthreads/"&gt;https://computing.llnl.gov/tutorials/pthreads/&lt;/a&gt;&lt;br /&gt;</description>
      <pubDate>Tue, 06 Jan 2009 08:19:36 -0700</pubDate>
    </item>
    <item>
      <title>Re: Pointer to Char Problem</title>
      <link />
      <description>&lt;p&gt;Posted a 'reply on the C and C++ forum.&lt;/p&gt;First you declare&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
char* Name;
&lt;/pre&gt;&lt;br /&gt;
while you use&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
cin.getline(name, 15);
&lt;/pre&gt;&lt;br /&gt;
&lt;em&gt;Name&lt;/em&gt; and &lt;em&gt;name&lt;/em&gt; are different, but I guess you have corrected it.&lt;br /&gt;
Also&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
cout &amp;lt;&amp;lt; line;
&lt;/pre&gt;&lt;br /&gt;
Where do you declare &lt;em&gt;line&lt;/em&gt;? I doubt this code compiled in that form...&lt;br /&gt;
&lt;br /&gt;
So to correct your code in this form follow the suggestion of allocating memory for the pointer. For example...&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
char* name = (char*) malloc(SIZE_IN_BYTES_OF_MEMORY_REQUESTED);
&lt;/pre&gt;&lt;br /&gt;
Do not forget to free it up when done using it.&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
free(name);
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Finally, since you use using C++ you are better off using C++ facilities, like the string class. So you could make these changes&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
 #include &amp;lt;iostream&amp;gt;
&lt;span style="color: Green;"&gt;+#include &amp;lt;string&amp;gt;&lt;/span&gt;
 using namespace std;
 
 int main()
 {
&lt;span style="color: Red;"&gt;-  char *name = (char*) malloc(20);&lt;/span&gt;
&lt;span style="color: Green;"&gt;+  string name;&lt;/span&gt;
   cout &amp;lt;&amp;lt; " Enter your name with space(E.g Joe Mark)\n";
&lt;span style="color: Red;"&gt;-  cin.getline(name, 20);&lt;/span&gt;
&lt;span style="color: Green;"&gt;+  getline(cin, name);&lt;/span&gt;
   cout &amp;lt;&amp;lt; name;
&lt;span style="color: Red;"&gt;-  free(name);&lt;/span&gt;
   system("pause");
   return 0;
 }
&lt;/pre&gt;&lt;br /&gt;</description>
      <pubDate>Tue, 06 Jan 2009 08:11:17 -0700</pubDate>
    </item>
    <item>
      <title>Re: virus scanner</title>
      <link />
      <description>&lt;p&gt;Posted a 'reply on the Security forum.&lt;/p&gt;If you want to take a look at source code for an antivirus product try&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.clamav.net/download/sources"&gt;http://www.clamav.net/download/sources&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
The ClamAV product is licensed under GPL.</description>
      <pubDate>Tue, 06 Jan 2009 06:24:51 -0700</pubDate>
    </item>
    <item>
      <title>Re: Print all possible combination of 4 digit numbers</title>
      <link />
      <description>&lt;p&gt;Posted a 'reply on the C and C++ forum.&lt;/p&gt;Allow me a correction. What your program tries to do is find permutations not combinations.&lt;br /&gt;
&lt;br /&gt;
The number of permutations of N objects by using R (R &amp;lt;= N) objects simultaneously is given by this formula...&lt;br /&gt;
P(N,R) = N! / (N - R)!&lt;br /&gt;
&lt;br /&gt;
That said there are quite a few resources found online. For example &lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://newton.ex.ac.uk/teaching/jmr/recursion.html"&gt;http://newton.ex.ac.uk/teaching/jmr/recursion.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
There you will find an elegant algorithm for finding permutations as well as a fine introduction to recursion, a very powerful technique in coding.</description>
      <pubDate>Tue, 06 Jan 2009 06:10:29 -0700</pubDate>
    </item>
  </channel>
</rss>