#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define CMAX 52
#define BUFF_SIZE 256
struct input
{
int card[CMAX];
int num;
};
int comp(void);
int getcard(struct input *inp_card);
void print_card(const struct input *inp_card, const char *card[]);
int calc(const struct input *inp_card);
#define randmize() srand(time(NULL))
int main()
{
const static char* card[] = { "0","A","2","3","4","5","6","7","8","9","10","J","Q","K" };
int x;
int c_score;
int h_score;
char in[BUFF_SIZE];
struct input h_card = {{0}, 0};
printf("Blackjack Game \n");
randmize();
c_score = comp();
x = getcard( &h_card);
printf("you took the '%s'",card[x] );
printf("get a card (y/n)");
while (h_card.num < CMAX && fgets(in, BUFF_SIZE, stdin) != NULL)
{
if (strncmp(in, "y", 1) == 0)
{
x = getcard( &h_card);
printf("you took the '%s'", card[x]);
print_card(&h_card, card);
printf("get a card (y/n)");
}
else if
(strncmp(in, "n", 1) == 0)
break;
else
printf("type y or n.\n");
}
h_score = calc(&h_card);
printf("your score : %d\ncomputer score : %d\n", h_score, c_score);
if
(c_score <= 21 && (h_score > 21 || c_score > h_score))
printf("Computer WIN!\n");
else if
(h_score <= 21 && (c_score > 21 || h_score > c_score))
printf("You WIN!\n");
else
printf("Draw\n");
return 0;
}
right now I am trying to make a blackjack game with C in VisualStudio.
but it makes errors and i dont know why
how should i change my code?
it said error code LNK1120 and LNK2019,getcardmain,calcmain,compmain,print_cardmain
i think i have to fix getcard, print_card and calc
but i dont know how