X-Originating-IP: [208.160.246.197] From: "Nimrod Abing" To: djgpp AT delorie DOT com Cc: homie_dont_play_dat AT yahoo DOT com Subject: Re: Hello all. Im a new DJGPP user... Date: Wed, 23 Aug 2000 12:14:38 PHT Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 23 Aug 2000 04:14:38.0495 (UTC) FILETIME=[A731D2F0:01C00CB8] Reply-To: djgpp AT delorie DOT com >From: Chris Amos >Reply-To: djgpp AT delorie DOT com >To: djgpp AT delorie DOT com >Subject: Re: Hello all. Im a new DJGPP user... >Date: Tue, 22 Aug 2000 20:33:29 -0700 (PDT) > >Heres my first program. Tell me what you think, if there are any >structure errors or whatever. I dont think there are, but then again. >Im just a newbie... > >P.S.> Sorry about the Word wrap. :( > >-------- USING DJGGP/ALLEGRO FOR DOS -------- Your program should compile if you saved it as a C++ file. If look at your comments, // starts a comment in C++ and it will generate compile time errors with gcc. You can compile your code with this: (Assume file.cc) gxx file.cc -o file.exe -O3 -lalleg > >// Program by Twisted Matrix - My first graphical c program... >// Uses ALLEGRO and the DJGPP compiler > >#include // Which of these i acually use in this program >#include // is beyond me. Heh heh. I know i use Allegro.h. >:) >#include > >main() >{ > int x=0; /* Lets define some local variables */ > int col=0; /* Everyone loves integers! :) */ > > /* Initiate the Allegro library for use in this program */ > allegro_init(); > install_keyboard(); > set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0); > > /* Lets draw the 256 color palette shall we... */ > for (x=0; x<639; x++) > { col++; if (col>255) { col=0; } > vline(screen, x, 0, 479, col); } > > /* Now lets write a message on the screen and wait for a key press. >*/ > textout_centre(screen, font, "My first c program using >DJGPP/ALLEGRO", 320, 230, 15); > textout_centre(screen, font, "By: Twisted Matrix >(Homie_dont_play_dat AT Yahoo DOT com)", 320, 240, 15); > readkey(); > > return 0; // Can anyone tell me whats so special about 0? Why 0? You can return any value here. But ``return 0'' means that your program has finished and there were no runtime errors. Typically, you should return one of the values defined in errno.h when your program encounters errors during runtime and 0 (zero) when there are no errors. > // I mean, whats so special about it? Is is an exit code of > // some kind? Can i use any number I want or none at all? > // How about return 69; or return; ? Would those work? Yes, it is your program's exit code. And you can return any value. But just ``return;'' would generate a compile-time error: `return' with no value, in function returning non-void As to why this is important, take the program ``test'' for example (from Gnu sh-utils) it returns a value after evaluating its arguments. It returns a value of `0' (false) or `1' (true). ``test'' is used frequently in shell scripts. >} > >===== >~ Twisted Matrix (Founder of ULTRATECH) > >URL: http://www.stas.net/ultratech >Yahoo ID: Homie_dont_play_dat, ICQ: 74628745 >AOL im: TwistedMatrix > >__________________________________________________ >Do You Yahoo!? >Yahoo! Mail - Free email you can access from anywhere! >http://mail.yahoo.com/ ---------------- _nimrod_a_abing_ ------------------------------------------ Homepage: http://www.geocities.com/n_abing ________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com