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)
#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 */
}