From: "Al Morgan" Newsgroups: comp.os.msdos.djgpp Subject: Re: Compile trouble Date: Mon, 3 Jan 2000 22:01:25 -0800 Organization: Posted via Supernews, http://www.supernews.com Lines: 117 Message-ID: References: X-Complaints-To: newsabuse AT supernews DOT com X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com What command line are you using? Make sure to put " -lalleg" in there to include the allegro libraries. Al Morgan [ muaddib AT proaxis DOT com ] Chewbaklava wrote in message news:ktcc4.885$Y2 DOT 22000 AT harpo... > I created a small program to roll up a Dungeons and Dragons(role playing > game, not computer) character. It worked fine, then I added a function to > center the output, and I am getting 2 'undefined reference to main' link > errors. I have checked my syntax, although I miss stuff like that rather > easily. > > Also, in the line for(int i = 0; i < (80 - leng) / 2; i++), does i go out of > scope at the end of the for loop?? > > #include > #include "string.h" > #include "allegro.h" > > volatile int count; > > class PC > { > public: > int strength; > int inteligence; > int wisdom; > int dexterity; > int constitution; > int charisma; > > void random_scores() > { > strength = (rand() % 15) + 3; > inteligence = (rand() % 15) + 3; > wisdom = (rand() % 15) + 3; > dexterity = (rand() % 15) + 3; > constitution = (rand() % 15) + 3; > charisma = (rand() % 15) + 3; > } > > void print_scores() > { > cout << "\n Strength - " << strength; > cout << "\n Inteligence - " << inteligence; > cout << "\n Wisdom - " << wisdom; > cout << "\n Dexterity - " << dexterity; > cout << "\n Constitution - " << constitution; > cout << "\n Charisma - " << charisma; > } > }; > > void timer_handler() > { > count++; > } > END_OF_FUNCTION(timer_handler); > > void center(char *strng) > { > size_t leng; // Length of string > > leng = strlen(strng); > cout << "\n"; > > for (int i = 0; i < (80 - leng) / 2; i++) > cout << " "; > > cout << strng; > } > > int main() > { > int randomizer; // The variable to initialize the random number generator > PC Character; // The Character to be created > > allegro_init(); > install_keyboard(); > > // Title page and the setting of the random number generator seed. > > center("***** Dungeons and Dragons Character Generator *****\n"); > center("***** Version 1.0B *****\n\n"); > center("This program will generate the random\n"); > center("numbers to create a basic Duneons and\n"); > center("Dragons character. This is just the title\n"); > center("page, but I needed it to set the seed for the\n"); > center("random number generator, which must be varying\n"); > center("from program execution to program execution.\n\n"); > center("So, when you are ready, press any key to\n"); > center("set the random number generator seed and create a character...\n"); > > > install_int(timer_handler, 10); > LOCK_VARIABLE(count); > LOCK_FUNCTION(timer_handler); > > readkey(); > > randomizer = count; > srand(randomizer); > > Character.random_scores(); > Character.print_scores(); > > return 0; > } > > > >