GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 15-Nov-2004, 20:19
sosy2001 sosy2001 is offline
New Member
 
Join Date: Oct 2004
Posts: 12
sosy2001 is on a distinguished road

Need Help With Compiler Error


Here's the error message and code:
Linking...
main.obj : error LNK2001: unresolved external symbol _play
Debug/prn1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

prn1.exe - 2 error(s), 0 warning(s)

CPP / C++ / C Code:
#include <stdio.h>
#include <stdlib.h>

#define MAXWORD 100

int    get_call_from_user(void);
void   play(int how_many);
void   prn_final_report(int win, int lose, int how_many);
void   prn_instructions(void);
void   report_a_win(int coin);
void   report_a_loss(int coin);
int    toss(void);
------------------------------------------------------------------------
#include "heads.h"

int main(void)
{
   char   ans;
   int    no_of_plays;

   printf("\n"
      "THE GAME OF HEADS OR TAILS\n"
      "\n"
      "Do you want instructions?  ");
   scanf(" %c", &ans);
   putchar('\n');
   if (ans == 'y' || ans == 'Y')
      prn_instructions();
   printf("How many times do you want to play?  ");
   scanf("%d", & no_of_plays);
   putchar('\n');
   play( no_of_plays);
   return 0;
}
-------------------------------------------------------------------
#include "heads.h"

int get_call_from_user(void)
{
   int   guess;                /* 0 = heads, 1 = tails */

   do {
      printf("Call it:  ");
      if (scanf("%d", &guess) != 1) {
         printf("\nSORRY: Severe input error - bye!\n\n");
         exit(1);
      }
      if (guess != 0 && guess != 1) {
         printf("\n%s\n\n",
            "ERROR: Type 0 for heads, 1 for tails.");
      }
   } while (guess != 0 && guess != 1);
   return guess;
}
-----------------------------------------------------------------
#include "heads.h"

void prn_instructions(void)
{
   printf("%s\n",
      "This is the game of calling heads or tails.\n"
      "I will flip a coin; you call it.  If you\n"
      "call it correctly, you win; otherwise,\n"
      "I win.\n"
      "\n"
      "As I toss the (simulated) coin, I will\n"
      "tell you to \"call it.\"  To call heads,\n"
      "type 0; to call tails, type 1.\n"
      "\n");
}

void prn_final_report(int win, int lose, int how_many)
{
   printf("\n%s\n%s%3d\n%s%3d\n%s%3d\n\n",
      "FINAL REPORT:",
      "   Number of games that you won:  ", win,
      "   Number of games that you lost: ", lose,
      "   Total number of games:         ", how_many);
}
------------------------------------------------------------------
#include "heads.h"
  void report_a_win(int coin)
{
	printf("You win, it was a");
	if (coin)
	{
		printf("tail\n");
	}
	else
	{
		printf("head\n");
	}
	return;
}

void report_a_lose(int coin)
{
	printf("You lose, it was a");
	if (coin)
	{
		printf("tail\n");
	}
	else
	{
		printf("head\n");
	}
	return;
} 

int toss(void)
{
   return (rand() % 2);     /* 0 = heads, 1 = tails */
}
Last edited by LuciWiz : 25-Mar-2006 at 18:39. Reason: Please insert your C code between [c] & [/c] tags
 
 

Recent GIDBlogRunning Linux Programs at Boot Time by gidnetwork

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Tutorial] GUI programming with FLTK dsmith FLTK Forum 10 03-Oct-2005 15:41
Operator Overloading: << aaroncohn C++ Forum 36 07-Dec-2004 19:22
link error? pablowablo C++ Forum 14 19-Jun-2004 10:00
OpenGL always reports error mvt OpenGL Programming 2 04-Jun-2004 06:42
Visual C++ 6 Compiler error vip3r C++ Forum 2 13-Apr-2004 14:34

Network Sites: GIDNetwork · GIDApp · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 07:37.


vBulletin, Copyright © 2000 - 2013, Jelsoft Enterprises Ltd.