From: "Chewbaklava" Newsgroups: comp.os.msdos.djgpp Subject: Compile trouble Lines: 104 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 Message-ID: Date: Mon, 3 Jan 2000 21:00:14 -0500 NNTP-Posting-Host: 209.222.102.127 X-Trace: harpo 946951120 209.222.102.127 (Mon, 03 Jan 2000 20:58:40 EST) NNTP-Posting-Date: Mon, 03 Jan 2000 20:58:40 EST To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com 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; }