delorie.com/archives/browse.cgi | search |
From: | "pcgamesmaster AT hotmail DOT com" <pcgamesmaster AT hotmail DOT com> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | funny for and while loop and c++ problems |
Date: | Fri, 05 Feb 1999 01:17:58 +0800 |
Organization: | Singapore Telecommunications Ltd |
Lines: | 82 |
Message-ID: | <36B9D646.DFD01E97@hotmail.com> |
NNTP-Posting-Host: | qtns01636.singnet.com.sg |
Mime-Version: | 1.0 |
X-Mailer: | Mozilla 4.04 [en] (Win95; I) |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
question 1: what is the difference between the first and second snippet of code? why doesn't the first one work in djgpp? ======================================================================== lp = 0; while (!key[KEY_ENTER]) { while (lp < 256) { if (pal[lp].r > 0) { pal[lp].r--; } if (pal[lp].g > 0) { pal[lp].g--; } if (pal[lp].b > 0) { pal[lp].b--; } lp += 1; } set_palette(pal); } ======================================================================== while (!key[KEY_ENTER]) { for (lp = 0; lp < 256; lp++) { if (pal[lp].r > 0) { pal[lp].r--; } if (pal[lp].g > 0) { pal[lp].g--; } if (pal[lp].b > 0) { pal[lp].b--; } } set_palette(pal); } ======================================================================== i think the problem with the first one is that it doesn't execute the innermost while loop. why? this is part of a program using the allegro graphics library to fade a display to black. however, the display using the first snippet of code doesn't work, while the second does ... question 2: while i attempt to compile c++ code in djgpp using the command-line gcc <filename.cpp> djgpp returns me with ======================================================================== c:/djgpp/tmp\ccdaaaaa(.text+0x1a):testcpp.cc: undefined reference to `endl(ostream &)' c:/djgpp/tmp\ccdaaaaa(.text+0x24):testcpp.cc: undefined reference to `cout' c:/djgpp/tmp\ccdaaaaa(.text+0x29):testcpp.cc: undefined reference to `ostream::operator<<(char const *)' c:/djgpp/tmp\ccdaaaaa(.text+0x34):testcpp.cc: undefined reference to `ostream::operator<<(ostream &(*)(ostream &))' ======================================================================== this is the program listing : ======================================================================== #include <iostream.h> main() { cout << "Hello World!" << endl; } ======================================================================== how do i compile c++ code in djgpp? thanks in advance for any help given ... lee.
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |