Right, so it's been a long while since I did any programming so I decided to try somthing simple and make a card dealing program and i'm getting an error I can't make heads nor tails of so could some one tell me what I'm doing wrong?
// Card dealing program.cpp : Defines the entry point for the console application.
//
#include <stdafx.h>
#include <stdlib.h>
#include <iostream>
#include <time.h>
#include <math.h>
#include <string>
using namespace std;
int Rand_0toN(int n);
int Deck[3][13];
int Drawcard();
bool Checkdeck();
void ResetDeck();
int drawcardloop = 1;
int Cardsleft;
bool debug = true;
string suits[4] = {"Hearts","Diamonds","Spades","Clubs"};
string ranks[13] = {"Ace","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"};
int main()
{
Cardsleft = 52;
int n = 0, i, d = 0;
srand(time(NULL));
ResetDeck();
while (1)
{
cout << "How many cards would you like to draw? type 0 to exit" << endl;
cin >> n;
if (n == 0)
{
break;
}
for (i = 1; i <=n; i++)
{
if (d == 1)
{
break;
}
d = Drawcard();
}
if (d == 1)
{
break;
}
cout << "There are " << Cardsleft << "Card(s) left" << endl;
}
return 0;
}
int Drawcard()
{
bool newcard = false;
int r = 0;
int s = 0;
int input;
int card;
if (Cardsleft <= 0)
{
while(1)
{
cout << "There are no cards left, type 1 to shuffle the deck, type 0 to exit program" << endl;
cin >> input;
if(input == 1)
{
ResetDeck();
Cardsleft = 51;
if (debug == true)
{
drawcardloop = 1;
}
break;
}
if(input == 0)
{
return 1;
break;
}
else
{
cout << "you did not enter a Valid number, please try again" << endl;
}
}
}
else
{
while (newcard == false)
{
card = Rand_0toN(52);
s = card / 13;
r = card % 13;
if (Deck [s][r] == 1){
newcard = false;
}
else
{
Cardsleft = Cardsleft - 1;
Deck [s][r] = 1;
break;
}
}
}
cout << ranks[r] <<" of " << suits [s] << endl;
if (debug == true)
{
cout << drawcardloop << endl;
drawcardloop = drawcardloop +1;
}
return 0;
}
int Rand_0toN(int n)
{
return rand() % n;
}
void ResetDeck()
{
int s,r;
for (s = 1; s <=3; s++)
{
for (r = 1; r <=13; r++)
{
Deck[s][r] = 0;
}
}
}
the errors i get are
Compiling...
Card dealing program.cpp
c:\users\martin\documents\visual studio 2008\projects\card dealing program\card dealing program\card dealing program.cpp(20) : warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data
Linking...
MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
C:\Users\Martin\Documents\Visual Studio 2008\Projects\Card dealing program\Debug\Card dealing program.exe : fatal error LNK1120: 1 unresolved externals
EDIT : i bet it somthing really simple.