Unresolved Externals Error

Hello, I have written a simple console card game, it is supposed to give the player five random cards ranging from 1 to 13 via "rand()%13+1" instruction then calculate your score. In order to win you have to get a higher score than the computer's.

When I try to debug it, it says "error:unresolved externals", I'm using Microsoft Visual C++ 10. Could you help me? Thanks in advance.

Here's my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include<iostream>
#include<string>
#include<vector>
#include<time.h>
#include<stdlib.h>
#include<conio.h>
#include<algorithm>

using namespace std;

int cards(vector <int> deck, vector<int> p1,vector <int> p2);
int discard(vector<int> deck, vector<int> p1);
int win_lose(vector<int> p1, vector<int> p2);

int main()
{ system("color A1");
  vector<int> deck;
  srand(time(0));
  deck.reserve(51);
  vector <int> p1,p2;
  cards(deck,p1,p2);
  cout<<"Your cards are:";
  for(int i=0; i<5;++i)
  {cout<<p1[i]<<" ";} 
  win_lose(p1,p2);
  _getch();
  return 0;
}

int cards(vector <int> deck, vector<int> p1,vector <int> p2)
{ for(int i=1; i<=14; ++i)
   for(int y=0; y<5; ++y)
   { deck.push_back(i);}
   random_shuffle(deck.begin(),deck.end());
   for(int i=0; i<5; ++i) { p1.push_back(deck[i]);}
   for(int i=0; i<5; ++i) { p2.push_back(deck[i+5]);}
   return 0;}


int discard(vector<int> deck, vector<int> p1)
{ cout<<"\n How many cards would you like to discard?\n";
  cout<<"(type 1, 2, or 3, 0 if you wisk to discard no card)\n";
  int wish_discard; int c_discard=0;
  cin>>wish_discard;
  while(c_discard<wish_discard)
  { cout<<"\n Which card would you like to discard?\n(1 for first, 2 for second and so on)\n";
    int wish; cin>>wish;
	while(wish>5) { cout<<"\nYou have only 5 cards in your hand! Please chose a valid one!\n"; cin>>wish;}
	p1[wish]=rand()%13+1;
	cout<<"Your cards are:";
	for(int i=0; i<5;++i)
	{ cout<<p1[i]<<"\t";} } 
     return 0;}

  int win_lose(vector<int> p1, vector<int> p2)
  { cout<<"\nYour opponent cards are:\n";
    for(int i=0; i<5;++i)
	{ cout<<p2[i+5]<<"\t";}
	int p1bonus=p1[0]+p1[1]+p1[2]+p1[3]+p1[4];
	int p2bonus=p1[0+5]+p1[1+5]+p1[2+5]+p1[3+5]+p1[4+5];
	cout<<"\nYour score is:"<<p1bonus<<endl;
	cout<<"\nYour opponent's score is:"<<p2bonus<<endl;
	if(p1>p2) {cout<<"Congrats, you won!";}
	else if(p2<p1) {cout<<"Bad luck, you lose!";}
	else {cout<<"It's a tie!";}
	return 0;}
Last edited on
If you don't understand the error message, why do you cut it leaving out the important parts.

PS: learn to indent.
Here's the exact error:

fatal error LNK1120: 1 unresolved externals
closed account (j3Rz8vqX)
Possibly this:
http://stackoverflow.com/questions/7410798/c-fatal-error-lnk1120-1-unresolved-externals

Looks like a project linking error.
@LizardEye: in that case I strongly recommend you to change your build tools. Such a message is useless
See in the link posted by `Dput' how at least say the name of the symbol.
@ne555:It doesn't say which symbol, it doesn't underline it, it doesn't say on which line, it only says:
1
2
3
1
1>LINK : error LNK2001: unresolved external symbol _mainCRTStartup
1>C:\Users\me\documents\visual studio 2010\Projects\cardgame\Debug\cardgame.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


@Dput: Thanks, it works.
Last edited on
Topic archived. No new replies allowed.