<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>C and C++ Forum RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest threads from the 'C and C++' forum at Programmer's Heaven, excluding replies.</description>
    <language>en</language>
    <copyright>Copyright 2012 Programmers Heaven</copyright>
    <pubDate>Thu, 09 Feb 2012 04:01:12 -0800</pubDate>
    <lastBuildDate>Thu, 09 Feb 2012 04:01:12 -0800</lastBuildDate>
    <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>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>fatal error: libtcc.h: No such file or directory</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/427305/427305/fatal-error-libtcch-no-such-file-or-directory/</link>
      <description>Hello,&lt;br /&gt;
With C code, I get this error:&lt;br /&gt;
fatal error: libtcc.h: No such file or directory &lt;br /&gt;
&lt;br /&gt;
The code includes the library: "#include &amp;lt;libtcc.h&amp;gt;".&lt;br /&gt;
&lt;br /&gt;
Can you tell me what I should do to resolve the error.&lt;br /&gt;
Thank you.&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/427305/427305/fatal-error-libtcch-no-such-file-or-directory/</guid>
      <pubDate>Wed, 08 Feb 2012 15:04:24 -0800</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>fatal error: libtcc.h: No such file or directory</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/427304/427304/fatal-error-libtcch-no-such-file-or-directory/</link>
      <description>Hello,&lt;br /&gt;
With C code, I get this error:&lt;br /&gt;
fatal error: libtcc.h: No such file or directory &lt;br /&gt;
&lt;br /&gt;
The code includes the library: "#include &amp;lt;libtcc.h&amp;gt;".&lt;br /&gt;
&lt;br /&gt;
Can you tell me what I should do to resolve the error.&lt;br /&gt;
Thank you.&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/427304/427304/fatal-error-libtcch-no-such-file-or-directory/</guid>
      <pubDate>Wed, 08 Feb 2012 14:56:53 -0800</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Help needed urgently regarding c++ or java programming !!!</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/427297/427297/help-needed-urgently-regarding-c++-or-java-programming-/</link>
      <description>Hey guys I have one programming assignment deadline on Feb 19th ..!! I am very bad at programming and I need your help!! Please anyone can come for a solution for my assignment??? I will be thankful to you very much !! Have a look at attached file for my programming assignment details !! It says that I need to develop a file sharing program like bit torrent with certain specifications ! please help guys !! Thanks for all your help in advance !!!&lt;br /&gt;
&lt;br&gt;&lt;br&gt;&lt;strong&gt;Attachment:&lt;/strong&gt; &lt;a href="http://www.programmersheaven.com/mb/DownloadAttachment.aspx?AttachmentID=2303"&gt;prog1_new.pdf&lt;/a&gt; (43932 bytes | downloaded 5 times)</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/427297/427297/help-needed-urgently-regarding-c++-or-java-programming-/</guid>
      <pubDate>Wed, 08 Feb 2012 01:07:29 -0800</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>dev c/c++: C Sample code to turn on/off pixel in window  and...</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/427261/427261/dev-cc++-c-sample-code-to-turn-onoff-pixel-in-window--and/</link>
      <description>Hi!&lt;br /&gt;
&lt;br /&gt;
In c language using dev c/c++ (dont ask why, thats the enviroment I know well)&lt;br /&gt;
&lt;br /&gt;
I want a sample code to create window and turn on off pixel. I want it to be as much as simple (with explanations if possible) and small the code.&lt;br /&gt;
&lt;br /&gt;
Also how to read a key and how to make the whole program run in desktop's background as overlay (like winamp's avs visualizations, check how simple and fast it is; i think it access ONLY the bitmap of the image being displayed or something like this..)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Also, where can I find a manual for the windows.h commands?</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/427261/427261/dev-cc++-c-sample-code-to-turn-onoff-pixel-in-window--and/</guid>
      <pubDate>Mon, 06 Feb 2012 11:40:33 -0800</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Please Help me</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/427249/427249/please-help-me/</link>
      <description>Please help me.&lt;br /&gt;
I need to create a Rat Race with Cheat.&lt;br /&gt;
and the codes are limited to "do,if,while,for" please check my codes and can someone fix it? xD&lt;br /&gt;
&lt;br /&gt;
This is just an easy problem for you guys so please do help me i need to pass this to my teacher this afternood i have 5 hours left&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Said cheat is when the race start and in the middle of the race the   &lt;br /&gt;
user will press a number from 1-15 the number that's been pressed will win the race and if the user decided to change the winner he will press a number again.&lt;br /&gt;
the race is from X 10-70 lines&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include&amp;lt;conio.h&amp;gt;&lt;br /&gt;
#include&amp;lt;dos.h&amp;gt;&lt;br /&gt;
#include&amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include&amp;lt;time.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  clrscr();&lt;br /&gt;
  int rats, numrats, go, key, x, y, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15;&lt;br /&gt;
  char c;&lt;br /&gt;
  r1=r2=r3=r4=r5=r6=r7=r8=r9=r10=r11=r12=r13=r14=r15
=1;&lt;br /&gt;
  textmode(2);&lt;br /&gt;
  rats=1;&lt;br /&gt;
  x=1;&lt;br /&gt;
  go=5;&lt;br /&gt;
  clrscr();&lt;br /&gt;
  gotoxy(1,16);&lt;br /&gt;
  printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c
%c%c%c%c%c%c%c%c%c%c%c\n",201,205,205,205,205,205,
205,205,205,205,205,205,205,205,205,205,205,205,20
5,205,205,205,205,205,205,205,205,205,205,205,205,
187);&lt;br /&gt;
  printf("%c Welcome to rat race of Awtz! %c\n",186,186);&lt;br /&gt;
  printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c
%c%c%c%c%c%c%c%c%c%c%c\n",200,205,205,205,205,205,
205,205,205,205,205,205,205,205,205,205,205,205,20
5,205,205,205,205,205,205,205,205,205,205,205,205,
188);&lt;br /&gt;
  getch();&lt;br /&gt;
  printf("Enter number of rats:");&lt;br /&gt;
  scanf("%d",&amp;amp;numrats);&lt;br /&gt;
  while (numrats&amp;lt;10||numrats&amp;gt;15)&lt;br /&gt;
    {&lt;br /&gt;
    printf("Enter a number within 10-15 (to start the race):");&lt;br /&gt;
    scanf("%d",&amp;amp;numrats);&lt;br /&gt;
    }&lt;br /&gt;
  clrscr();&lt;br /&gt;
  for(numrats;rats&amp;lt;=numrats;rats++)&lt;br /&gt;
    {&lt;br /&gt;
    delay(200);&lt;br /&gt;
    printf("%2d %8s\n\a",rats,"&amp;gt;");&lt;br /&gt;
    }&lt;br /&gt;
    gotoxy(1,16);&lt;br /&gt;
  printf("Start? &amp;lt;Y/N&amp;gt;\n");&lt;br /&gt;
  c=getch();&lt;br /&gt;
  kbhit();&lt;br /&gt;
  if(c==89||c==121)&lt;br /&gt;
  {&lt;br /&gt;
      for(go;go&amp;gt;=1;go--)&lt;br /&gt;
      {&lt;br /&gt;
      delay(500);&lt;br /&gt;
      printf("\n%d\a",go);&lt;br /&gt;
      }&lt;br /&gt;
      delay(1000);&lt;br /&gt;
    printf("\nGO !!!");&lt;br /&gt;
  }&lt;br /&gt;
  else&lt;br /&gt;
  {&lt;br /&gt;
  if(c==78||c==110)&lt;br /&gt;
  {&lt;br /&gt;
    printf("Okay. just press Y if you want to start the race\n");&lt;br /&gt;
    c=getch();&lt;br /&gt;
    kbhit();&lt;br /&gt;
      if(c==89||c==121)&lt;br /&gt;
      {&lt;br /&gt;
	for(go;go&amp;gt;=1;go--)&lt;br /&gt;
	{&lt;br /&gt;
	delay(500);&lt;br /&gt;
	printf("\n%d\a",go);&lt;br /&gt;
	}&lt;br /&gt;
	printf("\nGO !!!");&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
  }&lt;br /&gt;
  while(x!=70)&lt;br /&gt;
  {&lt;br /&gt;
    if(x&amp;lt;70)&lt;br /&gt;
    {&lt;br /&gt;
    y=random(rats);&lt;br /&gt;
    {&lt;br /&gt;
      if(y==1)&lt;br /&gt;
	{&lt;br /&gt;
	x=r1;&lt;br /&gt;
	r1++;&lt;br /&gt;
	}&lt;br /&gt;
      if(y==2)&lt;br /&gt;
	{&lt;br /&gt;
	x=r2;&lt;br /&gt;
	r2++;&lt;br /&gt;
	}&lt;br /&gt;
      if(y==3)&lt;br /&gt;
	{&lt;br /&gt;
	x=r3;&lt;br /&gt;
	r3++;&lt;br /&gt;
	}&lt;br /&gt;
      if(y==4)&lt;br /&gt;
	{&lt;br /&gt;
	x=r4;&lt;br /&gt;
	r4++;&lt;br /&gt;
	}&lt;br /&gt;
      if(y==5)&lt;br /&gt;
	{&lt;br /&gt;
	x=r5;&lt;br /&gt;
	r5++;&lt;br /&gt;
	}&lt;br /&gt;
      if(y==6)&lt;br /&gt;
	{&lt;br /&gt;
	x=r6;&lt;br /&gt;
	r6++;&lt;br /&gt;
	}&lt;br /&gt;
      if(y==7)&lt;br /&gt;
	{&lt;br /&gt;
	x=r7;&lt;br /&gt;
	r7++;&lt;br /&gt;
	}&lt;br /&gt;
      if(y==8)&lt;br /&gt;
	{&lt;br /&gt;
	x=r8;&lt;br /&gt;
	r8++;&lt;br /&gt;
	}&lt;br /&gt;
      if(y==9)&lt;br /&gt;
	{&lt;br /&gt;
	x=r9;&lt;br /&gt;
	r9++;&lt;br /&gt;
	}&lt;br /&gt;
      if(y==10)&lt;br /&gt;
	{&lt;br /&gt;
	x=r10;&lt;br /&gt;
	r10++;&lt;br /&gt;
	}&lt;br /&gt;
      if(y==11)&lt;br /&gt;
	{&lt;br /&gt;
	x=r11;&lt;br /&gt;
	r11++;&lt;br /&gt;
	}&lt;br /&gt;
      if(y==12)&lt;br /&gt;
	{&lt;br /&gt;
	x=r12;&lt;br /&gt;
	r12++;&lt;br /&gt;
	}&lt;br /&gt;
      if(y==13)&lt;br /&gt;
	{&lt;br /&gt;
	x=r13;&lt;br /&gt;
	r13++;&lt;br /&gt;
	}&lt;br /&gt;
      if(y==14)&lt;br /&gt;
	{&lt;br /&gt;
	x=r14;&lt;br /&gt;
	r14++;&lt;br /&gt;
	}&lt;br /&gt;
      else&lt;br /&gt;
	{&lt;br /&gt;
	x=r15;&lt;br /&gt;
	r15++;&lt;br /&gt;
      }&lt;br /&gt;
    delay(500);&lt;br /&gt;
    gotoxy(x,y);&lt;br /&gt;
    printf("&amp;gt;");&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  }&lt;br /&gt;
  getch();&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/427249/427249/please-help-me/</guid>
      <pubDate>Sun, 05 Feb 2012 15:17:47 -0800</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Angle between 2 3d vectors</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/427245/427245/angle-between-2-3d-vectors/</link>
      <description>&lt;br /&gt;
&lt;br /&gt;
Hi, &lt;br /&gt;
&lt;br /&gt;
Im after getting help on finding the signed angle between 2 3d vectors.&lt;br /&gt;
&lt;br /&gt;
i have 2 vectors that can rotate, i want to get the angle from vector 1 to vector 2 taking into account the rotation of the vector.&lt;br /&gt;
&lt;br /&gt;
i have this robot which spins the top half of its body, if its not facing the other vector i need the angle to make this top body part rotate to face the other vector.&lt;br /&gt;
&lt;br /&gt;
ive scoured the internet for days however everything i have tried has failed.&lt;br /&gt;
&lt;br /&gt;
can anyone help with this.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/427245/427245/angle-between-2-3d-vectors/</guid>
      <pubDate>Sun, 05 Feb 2012 14:27:59 -0800</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Angle between 2 3d vectors</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/427244/427244/angle-between-2-3d-vectors/</link>
      <description>&lt;br /&gt;
Hi, &lt;br /&gt;
&lt;br /&gt;
Im after getting help on finding the signed angle between 2 3d vectors.&lt;br /&gt;
&lt;br /&gt;
i have 2 vectors that can rotate, i want to get the angle from vector 1 to vector 2 taking into account the rotation of the vector.&lt;br /&gt;
&lt;br /&gt;
i have this robot which spins the top half of its body, if its not facing the other vector i need the angle to make this top body part rotate to face the other vector.&lt;br /&gt;
&lt;br /&gt;
ive scoured the internet for days however everything i have tried has failed.&lt;br /&gt;
&lt;br /&gt;
can anyone help with this.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/427244/427244/angle-between-2-3d-vectors/</guid>
      <pubDate>Sun, 05 Feb 2012 14:26:08 -0800</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>help for recognition solution</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/427239/427239/help-for-recognition-solution/</link>
      <description>which type of algorithm is better to solve this task:&lt;br /&gt;
&lt;br /&gt;
i have an"image" presented in ASCII text, where "." is white color, "%" is light grey, "#" is dark grey and "@" is black. And image shows some numbers like 545, 839, 901, 834 and so on, every combination of hundreds numbers.&lt;br /&gt;
&lt;br /&gt;
And i need to find what number is drown on text file via symbols above.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can see an example on attachment.&lt;br /&gt;
&lt;br /&gt;
Regards.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br&gt;&lt;br&gt;&lt;strong&gt;Attachment:&lt;/strong&gt; &lt;a href="http://www.programmersheaven.com/mb/DownloadAttachment.aspx?AttachmentID=2291"&gt;example_numbers.rar&lt;/a&gt; (239 bytes | downloaded 5 times)</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/427239/427239/help-for-recognition-solution/</guid>
      <pubDate>Sun, 05 Feb 2012 07:01:34 -0800</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>help for recognition solution</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/427238/427238/help-for-recognition-solution/</link>
      <description>which type of algorithm is better to solve this task:&lt;br /&gt;
&lt;br /&gt;
i have an"image" presented in ASCII text, where "." is white color, "%" is light grey, "#" is dark grey and "@" is black. And image shows some numbers like 545, 839, 901, 834 and so on, every combination of hundreds numbers.&lt;br /&gt;
&lt;br /&gt;
And i need to find what number is drown on text file via symbols above.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can see an example on attachment.&lt;br /&gt;
&lt;br /&gt;
Regards.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/427238/427238/help-for-recognition-solution/</guid>
      <pubDate>Sun, 05 Feb 2012 06:57:22 -0800</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>recognition algorithm</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/427237/427237/recognition-algorithm/</link>
      <description>which type of algorithm is better to solve this task:&lt;br /&gt;
&lt;br /&gt;
i have an"image" presented in ASCII text, where "." is white color, "%" is light grey, "#" is dark grey and "@" is black. And image shows some numbers like 545, 839, 901, 834 and so on, every combination of hundreds numbers.&lt;br /&gt;
&lt;br /&gt;
And i need to find what number is drown on text file via symbols above.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can see an example on attachment.&lt;br /&gt;
&lt;br /&gt;
Regards.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/427237/427237/recognition-algorithm/</guid>
      <pubDate>Sun, 05 Feb 2012 06:52:46 -0800</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>recognition algorithm</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/427236/427236/recognition-algorithm/</link>
      <description>which type of algorithm is better to solve this task:&lt;br /&gt;
&lt;br /&gt;
i have an"image" presented in ASCII text, where "." is white color, "%" is light grey, "#" is dark grey and "@" is black. And image shows some numbers like 545, 839, 901, 834 and so on, every combination of hundreds numbers.&lt;br /&gt;
&lt;br /&gt;
And i need to find what number is drown on text file via symbols above.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can see an example on attachment.&lt;br /&gt;
&lt;br /&gt;
Regards.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/427236/427236/recognition-algorithm/</guid>
      <pubDate>Sun, 05 Feb 2012 06:48:31 -0800</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Odd compilation errors</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/427056/427056/odd-compilation-errors/</link>
      <description>Hi folks,&lt;br /&gt;
I am having some problems with a code listing my lecturer sent me to work on. The keyboard function is throwing two errors on compilation.&lt;br /&gt;
arrors are &lt;br /&gt;
1&amp;gt;main.cpp(77) : error C2143: syntax error : missing ';' before 'constant'&lt;br /&gt;
1&amp;gt;main.cpp(77) : error C2106: '=' : left operand must be l-value&lt;br /&gt;
&lt;br /&gt;
the line that appears to be causing the error is in the following function, highlighted in red.&lt;br /&gt;
&lt;br /&gt;
void keyboard(unsigned char key, int x, int y)&lt;br /&gt;
{&lt;br /&gt;
&lt;span style="color: Red;"&gt;const unsigned char VK_ESCAPE=0x1b;&lt;/span&gt;&lt;br /&gt;
	switch (key) {&lt;br /&gt;
		case 'r':       // Red&lt;br /&gt;
			glColor3f(1.0, 0.0, 0.0);&lt;br /&gt;
			break;&lt;br /&gt;
		case 'g':       // Green&lt;br /&gt;
			glColor3f(0.0, 1.0, 0.0);&lt;br /&gt;
			break;&lt;br /&gt;
		case 'b':       // Blue&lt;br /&gt;
			glColor3f(0.0, 0.0, 1.0);&lt;br /&gt;
			break;&lt;br /&gt;
		case 'k':       // Black&lt;br /&gt;
			glColor3f(0.0, 0.0, 0.0);&lt;br /&gt;
			break;&lt;br /&gt;
		// Extra statements added to change the background colour...&lt;br /&gt;
		case 'R':		// Red background&lt;br /&gt;
			glClearColor(1, 0, 0, 1);&lt;br /&gt;
			glClear(GL_COLOR_BUFFER_BIT);&lt;br /&gt;
			break;&lt;br /&gt;
		case 'G':		// Green background&lt;br /&gt;
			glClearColor(0, 1, 0, 1);&lt;br /&gt;
			glClear(GL_COLOR_BUFFER_BIT);&lt;br /&gt;
			break;&lt;br /&gt;
		case 'B':		// Blue background&lt;br /&gt;
			glClearColor(0, 0, 1, 1);&lt;br /&gt;
			glClear(GL_COLOR_BUFFER_BIT);&lt;br /&gt;
			break;&lt;br /&gt;
		// Extra key handlers for line width...&lt;br /&gt;
		case '1':&lt;br /&gt;
			glLineWidth(1);&lt;br /&gt;
			break;&lt;br /&gt;
		case '2':&lt;br /&gt;
			glLineWidth(2);&lt;br /&gt;
			break;&lt;br /&gt;
		case '3':&lt;br /&gt;
			glLineWidth(3);&lt;br /&gt;
			break;&lt;br /&gt;
		case '4':&lt;br /&gt;
			glLineWidth(4);&lt;br /&gt;
			break;&lt;br /&gt;
		case '5':&lt;br /&gt;
			glLineWidth(5);&lt;br /&gt;
			break;&lt;br /&gt;
		case '6':&lt;br /&gt;
			glLineWidth(6);&lt;br /&gt;
			break;&lt;br /&gt;
		case VK_ESCAPE:	// Quit – the Esc key.&lt;br /&gt;
			exit(0);&lt;br /&gt;
			break;&lt;br /&gt;
		default:&lt;br /&gt;
			// could do stuff here also&lt;br /&gt;
			break;&lt;br /&gt;
	}&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
As I stated, my lecturer states that this code works fine, but I am having no luck. Any ideas?&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/427056/427056/odd-compilation-errors/</guid>
      <pubDate>Fri, 27 Jan 2012 10:40:45 -0800</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Odd compilation errors</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/427055/427055/odd-compilation-errors/</link>
      <description>Hi folks,&lt;br /&gt;
I am having some problems with a code listing my lecturer sent me to work on. The keyboard function is throwing two errors on compilation.&lt;br /&gt;
arrors are &lt;br /&gt;
1&amp;gt;main.cpp(77) : error C2143: syntax error : missing ';' before 'constant'&lt;br /&gt;
1&amp;gt;main.cpp(77) : error C2106: '=' : left operand must be l-value&lt;br /&gt;
&lt;br /&gt;
the line that appears to be causing the error is in the following function, highlighted in red.&lt;br /&gt;
&lt;br /&gt;
void keyboard(unsigned char key, int x, int y)&lt;br /&gt;
{&lt;br /&gt;
&lt;span style="color: Red;"&gt;const unsigned char VK_ESCAPE=0x1b;&lt;/span&gt;&lt;br /&gt;
	switch (key) {&lt;br /&gt;
		case 'r':       // Red&lt;br /&gt;
			glColor3f(1.0, 0.0, 0.0);&lt;br /&gt;
			break;&lt;br /&gt;
		case 'g':       // Green&lt;br /&gt;
			glColor3f(0.0, 1.0, 0.0);&lt;br /&gt;
			break;&lt;br /&gt;
		case 'b':       // Blue&lt;br /&gt;
			glColor3f(0.0, 0.0, 1.0);&lt;br /&gt;
			break;&lt;br /&gt;
		case 'k':       // Black&lt;br /&gt;
			glColor3f(0.0, 0.0, 0.0);&lt;br /&gt;
			break;&lt;br /&gt;
		// Extra statements added to change the background colour...&lt;br /&gt;
		case 'R':		// Red background&lt;br /&gt;
			glClearColor(1, 0, 0, 1);&lt;br /&gt;
			glClear(GL_COLOR_BUFFER_BIT);&lt;br /&gt;
			break;&lt;br /&gt;
		case 'G':		// Green background&lt;br /&gt;
			glClearColor(0, 1, 0, 1);&lt;br /&gt;
			glClear(GL_COLOR_BUFFER_BIT);&lt;br /&gt;
			break;&lt;br /&gt;
		case 'B':		// Blue background&lt;br /&gt;
			glClearColor(0, 0, 1, 1);&lt;br /&gt;
			glClear(GL_COLOR_BUFFER_BIT);&lt;br /&gt;
			break;&lt;br /&gt;
		// Extra key handlers for line width...&lt;br /&gt;
		case '1':&lt;br /&gt;
			glLineWidth(1);&lt;br /&gt;
			break;&lt;br /&gt;
		case '2':&lt;br /&gt;
			glLineWidth(2);&lt;br /&gt;
			break;&lt;br /&gt;
		case '3':&lt;br /&gt;
			glLineWidth(3);&lt;br /&gt;
			break;&lt;br /&gt;
		case '4':&lt;br /&gt;
			glLineWidth(4);&lt;br /&gt;
			break;&lt;br /&gt;
		case '5':&lt;br /&gt;
			glLineWidth(5);&lt;br /&gt;
			break;&lt;br /&gt;
		case '6':&lt;br /&gt;
			glLineWidth(6);&lt;br /&gt;
			break;&lt;br /&gt;
		case VK_ESCAPE:	// Quit – the Esc key.&lt;br /&gt;
			exit(0);&lt;br /&gt;
			break;&lt;br /&gt;
		default:&lt;br /&gt;
			// could do stuff here also&lt;br /&gt;
			break;&lt;br /&gt;
	}&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
As I stated, my lecturer states that this code works fine, but I am having no luck. Any ideas?&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/427055/427055/odd-compilation-errors/</guid>
      <pubDate>Fri, 27 Jan 2012 10:37:48 -0800</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>sizeof(struct) doens'nt match inside total size</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/427053/427053/sizeofstruct-doensnt-match-inside-total-size/</link>
      <description>Hello,&lt;br /&gt;
&lt;br /&gt;
I usually develop in C for embedded platform (mplab C18 from microchip) and I use very often struct.&lt;br /&gt;
&lt;br /&gt;
I began to work on a project on a PC and I encounter one weird behavior which I don't understand :&lt;br /&gt;
&lt;br /&gt;
1st, when I do the sizeof(short, long, int and char) I get :&lt;br /&gt;
&lt;br /&gt;
short : 2&lt;br /&gt;
long : 8&lt;br /&gt;
int : 4&lt;br /&gt;
char : 1&lt;br /&gt;
&lt;br /&gt;
In the following struct, the total size from (sizeof) is 6 but if I do the sum of the size of the differents elements, it should sum 5.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;typedef struct _test
{
	unsigned char a;
	unsigned short b; // 2 bytes
	unsigned char c : 4;
	unsigned char d : 4;
	unsigned char e : 2;
	unsigned char f : 6;
}test;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
so:&lt;br /&gt;
&lt;br /&gt;
a = 1 byte&lt;br /&gt;
b = 2 bytes&lt;br /&gt;
c + d = 1 byte&lt;br /&gt;
e + f = 1 byte&lt;br /&gt;
&lt;br /&gt;
Why do the compiler add an empty byte somewhere ?  At first, I though it was because the structs must be 2 bytes aligned but the following struct works fine :&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
typedef struct _test2
{
  unsigned char a;
  unsigned char b;
  unsigned char c;
}test2;

the sizeof gives me 3 bytes which is right.
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
If I only put 1 short in the structure, the structure is sized 2 bytes. but if I add an unsigned char, the size is not right...&lt;br /&gt;
&lt;br /&gt;
I can't understand whis this behavior and How to bypass this ?&lt;br /&gt;
&lt;br /&gt;
Thank you for your help !&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/427053/427053/sizeofstruct-doensnt-match-inside-total-size/</guid>
      <pubDate>Fri, 27 Jan 2012 08:07:04 -0800</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>sizeof(struct) doens'nt match inside total size</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/427052/427052/sizeofstruct-doensnt-match-inside-total-size/</link>
      <description>Hello,&lt;br /&gt;
&lt;br /&gt;
I usually develop in C for embedded platform (mplab C18 from microchip) and I use very often struct.&lt;br /&gt;
&lt;br /&gt;
I began to work on a project on a PC and I encounter one weird behavior which I don't understand :&lt;br /&gt;
&lt;br /&gt;
1st, when I do the sizeof(short, long, int and char) I get :&lt;br /&gt;
&lt;br /&gt;
short : 2&lt;br /&gt;
long : 8&lt;br /&gt;
int : 4&lt;br /&gt;
char : 1&lt;br /&gt;
&lt;br /&gt;
In the following struct, the total size from (sizeof) is 6 but if I do the sum of the size of the differents elements, it should sum 5.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;typedef struct _test
{
	unsigned char a;
	unsigned short b; // 2 bytes
	unsigned char c : 4;
	unsigned char d : 4;
	unsigned char e : 2;
	unsigned char f : 6;
}test;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
so:&lt;br /&gt;
&lt;br /&gt;
a = 1 byte&lt;br /&gt;
b = 2 bytes&lt;br /&gt;
c + d = 1 byte&lt;br /&gt;
e + f = 1 byte&lt;br /&gt;
&lt;br /&gt;
Why do the compiler add an empty byte somewhere ?  At first, I though it was because the structs must be 2 bytes aligned but the following struct works fine :&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
typedef struct _test2
{
  unsigned char a;
  unsigned char b;
  unsigned char c;
}test2;

the sizeof gives me 3 bytes which is right.
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
If I only put 1 short in the structure, the structure is sized 2 bytes. but if I add an unsigned char, the size is not right...&lt;br /&gt;
&lt;br /&gt;
I can't understand whis this behavior and How to bypass this ?&lt;br /&gt;
&lt;br /&gt;
Thank you for your help !&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/427052/427052/sizeofstruct-doensnt-match-inside-total-size/</guid>
      <pubDate>Fri, 27 Jan 2012 08:04:53 -0800</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>combine 4 bytes into a 32 bit number</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/427007/427007/combine-4-bytes-into-a-32-bit-number/</link>
      <description>I have 4 numbers:b1 b2 b3 b4 (b1 is MSB, b4 is LSB) and I want to combine them into one number of 32-bit as b1b2b3b4;tried the following but didn't work (i guess overflow):&lt;br /&gt;
&lt;br /&gt;
res = (unsigned long)((b4 &amp;amp; 0xFF) | (((unsigned long)(b3&amp;lt;&amp;lt;8)) &amp;amp; 0xFF00));&lt;br /&gt;
res = (unsigned long)(res | (((unsigned long)(b2&amp;lt;&amp;lt;16)) &amp;amp; 0xFF0000));&lt;br /&gt;
res = (unsigned long)(res |(((unsigned long)(b1&amp;lt;&amp;lt;24)) &amp;amp; 0xFF000000));&lt;br /&gt;
&lt;br /&gt;
b1 = 86; b2 = 120; b3 = 154; b4 = 188;&lt;br /&gt;
result should be : 1450744508 in decimal or 56789abc in hex&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/427007/427007/combine-4-bytes-into-a-32-bit-number/</guid>
      <pubDate>Wed, 25 Jan 2012 20:56:42 -0800</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>combine 4 bytes into a 32 bit number</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/427005/427005/combine-4-bytes-into-a-32-bit-number/</link>
      <description>I have 4 numbers:b1 b2 b3 b4 (b1 is MSB, b4 is LSB) and I want to combine them into one number of 32-bit as b1b2b3b4;tried the following but didn't work (i guess overflow):&lt;br /&gt;
&lt;br /&gt;
res = (unsigned long)((b4 &amp;amp; 0xFF) | (((unsigned long)(b3&amp;lt;&amp;lt;8)) &amp;amp; 0xFF00));&lt;br /&gt;
res = (unsigned long)(res | (((unsigned long)(b2&amp;lt;&amp;lt;16)) &amp;amp; 0xFF0000));&lt;br /&gt;
res = (unsigned long)(res |(((unsigned long)(b1&amp;lt;&amp;lt;24)) &amp;amp; 0xFF000000));&lt;br /&gt;
&lt;br /&gt;
b1 = 86; b2 = 120; b3 = 154; b4 = 188;&lt;br /&gt;
result should be : 1450744508 in decimal or 56789abc in hex&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/427005/427005/combine-4-bytes-into-a-32-bit-number/</guid>
      <pubDate>Wed, 25 Jan 2012 20:54:51 -0800</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>BCC++ in DOS int86x string length</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/426917/426917/bcc++-in-dos-int86x-string-length/</link>
      <description>This is my first post here. I will ask my question in the next post if this goes through. The previous attempt failed. See ya.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/426917/426917/bcc++-in-dos-int86x-string-length/</guid>
      <pubDate>Sun, 22 Jan 2012 07:05:15 -0800</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Event Handler in C++</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/426916/426916/event-handler-in-c++/</link>
      <description>Hey,&lt;br /&gt;
I am trying to create a game which requires the use of keyboard.The game is about falling items and I have to collect the item using the paddle .So I know that we can make the terminal to operate in raw mode and make the paddle move using the keyboard input.But i am not sure if it will work as efficiently as an event handler works in other languages.&lt;br /&gt;
Is there any way that we can make it look like a REAL time event?&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/426916/426916/event-handler-in-c++/</guid>
      <pubDate>Sun, 22 Jan 2012 06:41:18 -0800</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Event Handler in C++</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/426915/426915/event-handler-in-c++/</link>
      <description>Hey,&lt;br /&gt;
I am trying to create a game which requires the use of keyboard.The game is about falling items and I have to collect the item using the paddle .So I know that we can make the terminal to operate in raw mode and make the paddle move using the keyboard input.But i am not sure if it will work as efficiently as an event handler works in other languages.&lt;br /&gt;
Is there any way that we can make it look like a REAL time event?&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/426915/426915/event-handler-in-c++/</guid>
      <pubDate>Sun, 22 Jan 2012 06:38:23 -0800</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Problem Writing To File (Dev C++ Compiler 4.9.9.2)</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/426877/426877/problem-writing-to-file-dev-c++-compiler-4992/</link>
      <description>Hello all,&lt;br /&gt;
I am trying to complete a summative programming for my grade 11 programming class and appear to be having some troubles when writing to file.  Any help is appreciated.&lt;br /&gt;
Code:&lt;pre class="sourcecode"&gt;int high_scores(string name, int points)
{
    int x, y, linecount, score[10], tick;
    string names[10];
    fstream WJ_names, WJ_points;
    WJ_names.open("WJ_Names.txt");
    WJ_points.open("WJ_Points.txt");
    for (x = 0; x &amp;lt;= 9; x++)
    {
        linecount = x;
        WJ_points &amp;gt;&amp;gt; score[x];
        WJ_points &amp;lt;&amp;lt; "";
        WJ_names &amp;gt;&amp;gt; names[x];
        WJ_names &amp;lt;&amp;lt; "";
        cout &amp;lt;&amp;lt; names[x] &amp;lt;&amp;lt; endl;
        cout &amp;lt;&amp;lt; score[x] &amp;lt;&amp;lt; endl;
        }
    y = 0;
    system("Pause");
    cout &amp;lt;&amp;lt; "----------------------------\n";
    do
    {
        if (points &amp;gt; score[y])
        {
                   score[y] = points;
                   names[y] = name;
                   tick = 1;
                   }
        y++;
        }while(tick == 0);
    for (x = 0; x &amp;lt;= 9; x++)
    {
        linecount = x;
        WJ_points &amp;lt;&amp;lt; score[x];
        WJ_names &amp;lt;&amp;lt; names[x];
        cout &amp;lt;&amp;lt; names[x] &amp;lt;&amp;lt; endl;
        cout &amp;lt;&amp;lt; score[x] &amp;lt;&amp;lt; endl;
        }
    WJ_points.close();
    WJ_names.close();
    return(0);
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
The reason why I don't really see a problem is because wouldn't declaring the variables in "fstream" make it possible to write and read from file?  The main problem is whats meant to happen is the user enters their name and the name is added to the "highscores" text file along with the "score/points".  But when I try to write to file, the file is the same as it was before (Without the new name added on)&lt;br /&gt;
&lt;br /&gt;
All help is appreciated.  :)&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/426877/426877/problem-writing-to-file-dev-c++-compiler-4992/</guid>
      <pubDate>Wed, 18 Jan 2012 20:38:26 -0800</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Problem Writing To File (Dev C++ Compiler 4.9.9.2)</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/426876/426876/problem-writing-to-file-dev-c++-compiler-4992/</link>
      <description>Hello all,&lt;br /&gt;
I am trying to complete a summative programming for my grade 11 programming class and appear to be having some troubles when writing to file.  Any help is appreciated.&lt;br /&gt;
Code:&lt;pre class="sourcecode"&gt;int high_scores(string name, int points)
{
    int x, y, linecount, score[10], tick;
    string names[10];
    fstream WJ_names, WJ_points;
    WJ_names.open("WJ_Names.txt");
    WJ_points.open("WJ_Points.txt");
    for (x = 0; x &amp;lt;= 9; x++)
    {
        linecount = x;
        WJ_points &amp;gt;&amp;gt; score[x];
        WJ_points &amp;lt;&amp;lt; "";
        WJ_names &amp;gt;&amp;gt; names[x];
        WJ_names &amp;lt;&amp;lt; "";
        cout &amp;lt;&amp;lt; names[x] &amp;lt;&amp;lt; endl;
        cout &amp;lt;&amp;lt; score[x] &amp;lt;&amp;lt; endl;
        }
    y = 0;
    system("Pause");
    cout &amp;lt;&amp;lt; "----------------------------\n";
    do
    {
        if (points &amp;gt; score[y])
        {
                   score[y] = points;
                   names[y] = name;
                   tick = 1;
                   }
        y++;
        }while(tick == 0);
    for (x = 0; x &amp;lt;= 9; x++)
    {
        linecount = x;
        WJ_points &amp;lt;&amp;lt; score[x];
        WJ_names &amp;lt;&amp;lt; names[x];
        cout &amp;lt;&amp;lt; names[x] &amp;lt;&amp;lt; endl;
        cout &amp;lt;&amp;lt; score[x] &amp;lt;&amp;lt; endl;
        }
    WJ_points.close();
    WJ_names.close();
    return(0);
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
The reason why I don't really see a problem is because wouldn't declaring the variables in "fstream" make it possible to write and read from file?  The main problem is whats meant to happen is the user enters their name and the name is added to the "highscores" text file along with the "score/points".  But when I try to write to file, the file is the same as it was before (Without the new name added on)&lt;br /&gt;
&lt;br /&gt;
All help is appreciated.  :)&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/426876/426876/problem-writing-to-file-dev-c++-compiler-4992/</guid>
      <pubDate>Wed, 18 Jan 2012 20:36:36 -0800</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Please help me..</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/426862/426862/please-help-me/</link>
      <description>I really want to seek help on the codes of this program. It's a multitasking using c++6. It can be found here. &lt;a href="http://impactnetworking.net/c1/ch18.htm"&gt;http://impactnetworking.net/c1/ch18.htm&lt;/a&gt;&lt;br /&gt;
Please if anyone knows how to modify and find out what's wrong with the codes, please help me. I have already tried it but it has some errors and i do not know how to solve it.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/426862/426862/please-help-me/</guid>
      <pubDate>Tue, 17 Jan 2012 23:28:02 -0800</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>How to Input to Program.</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/426811/426811/how-to-input-to-program/</link>
      <description>Hello All: This is my second C++ program. I'm trying to understand "cin". I run this program, it tells me what to do, I do it, hit enter, and the screen goes away. I don't know why. Please help. I am using Vista, IE7, Dev-C++.  &lt;br /&gt;
&lt;pre class="sourcecode"&gt;
#include &amp;lt;iostream&amp;gt;
#include &amp;lt;string&amp;gt;

using namespace std;

int main()
{
    string firstName;
    string lastName;
    int age;
    double weight;
    cout &amp;lt;&amp;lt; "Enter first name, last name, age, "
    &amp;lt;&amp;lt; "and weight, separated by spaces."
    &amp;lt;&amp;lt; endl;
    cin &amp;gt;&amp;gt; firstName &amp;gt;&amp;gt; lastName;
    cin &amp;gt;&amp;gt; age &amp;gt;&amp;gt; weight;
    
    cout &amp;lt;&amp;lt; "Age: " &amp;lt;&amp;lt; age &amp;lt;&amp;lt; endl;
    cout &amp;lt;&amp;lt; "Weight: " &amp;lt;&amp;lt; weight &amp;lt;&amp;lt; endl;
       getchar ();           

    return 0;
     
}
&lt;/pre&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/426811/426811/how-to-input-to-program/</guid>
      <pubDate>Sat, 14 Jan 2012 05:08:53 -0800</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>confusion regarding functions</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/426771/426771/confusion-regarding-functions/</link>
      <description>hi everyone!!!&lt;br /&gt;
I am new to c language,&lt;br /&gt;
can anyone tell me when to use which type of funtion in the program&lt;br /&gt;
.I always confuse about that.PLEASE HELP!!&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/426771/426771/confusion-regarding-functions/</guid>
      <pubDate>Wed, 11 Jan 2012 02:43:01 -0800</pubDate>
      <category>C and C++</category>
    </item>
  </channel>
</rss>
