Need help on this one error

// Bitay
#include <iostream>
#include <string>
#include <conio.h>
#include <time.h>


using namespace std;
int fill(char, string, string&);
const int tries = 5;

void cls()
{
cout << string(50, '\n');
}





int main()
{

int a;
int y =0;
char letter;
string word;
string category;
system("color A1");
srand( int( time( NULL ) ) );

cout<<"\n\n\n";
cout<<"\t\t\t\t"<<"++++++++++++++++++++++++++++++++++++++++"<<endl;
cout<<"\t\t\t\t"<<" +|BBBBBB BB BBBBBBBB BB BB BB |+"<<endl;
cout<<"\t\t\t\t"<<" +|BB BB BB BBBBBBBB BBBB BB BB |+"<<endl;
cout<<"\t\t\t\t"<<" +|BB BB BB BB BB BB BBBB |+"<<endl;
cout<<"\t\t\t\t"<<" +|BBBBBB BB BB BB BB BB |+"<<endl;
cout<<"\t\t\t\t"<<" +|BB BB BB BB BBBBBB BB |+"<<endl;
cout<<"\t\t\t\t"<<" +|BB BB BB BB BB BB BB |+"<<endl;
cout<<"\t\t\t\t"<<" +|BBBBBB BB BB BB BB BB |+"<<endl;
cout<<"\t\t\t\t"<<"++++++++++++++++++++++++++++++++++++++++"<<endl;

cout<< "\t\t\t\t\t" << "--------------------" << endl;
cout<< "\t\t\t\t\t" << "| 1. Single Player |" << endl;
cout<< "\t\t\t\t\t" << "| 2. Two PLayer |" << endl;
cout<< "\t\t\t\t\t" << "| 3. Quit |" << endl;
cout<< "\t\t\t\t\t" << "--------------------" << endl;
cout<< "\t\t\t\t\t" << "Selected : ";
cin>>a;

while (a<1 || a>2)

if (a=3)
{
return 0;
}
system ("cls");

if (a==1)
{
cout<<"Choose your category (A - Animals, P - Places, T - Things ) "<<endl;
cin>>category;

if (category == "Animals" )
{
string animals[] ={"dragonfly","kangaroo","lizard","elephant","cheetah","eagle","hawk","whale","tortoise","monkey","scorpion","crocodile","hamster","zebra","carabao","beaver","anglerfish","cockroach","spider","dog"};
string word;

int x = rand() % 20;
word = animals[x];

string hidden(word.length(), '_');
cout<<"Guess the right word by typing one letter every one try."<<endl;
cout<<"You have "<<tries<< "tries to guess the word.";
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;

while (y<tries)
{
cout<<"n\n"<<hidden;
cout << "\n\nGuess a letter: ";
cin >> letter;

if((fill(letter, word, hidden) == 0))
{
cout<<"Whoops!! That letter is not there."<<endl;
y++;
}
else
{
cout<<"You found a letter"<<endl;
}
cout<<"You have "<<tries-y<<"left"<<endl;
if (word==hidden)
{
cout<<word<<endl;
cout<<"You save yourself from being hanged"<<endl;
cout<<"You win!!"<<endl;
system("pause");
return 0;
}
}
if (y==tries)
{
cout << "\nYou lose!! You've been hanged." << endl;
cout << "The word was : " << word << endl;
}
cin.ignore();
cin.get();
return 0;

}

}



else if (a==2)
{
cout<<"noob"<<endl;
}





return 0;

}
Last edited on
closed account (48T7M4Gy)
http://www.cplusplus.com/forum/beginner/194394/
The error is
1>asdsa.obj : error LNK2019: unresolved external symbol "int __cdecl fill(char,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?fill@@YAHDV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAV12@@Z) referenced in function _main
1>C:\Users\Noah\Documents\Visual Studio 2005\Projects\Try Hangman\Debug\Try Hangman.exe : fatal error LNK1120: 1 unresolved externals
closed account (48T7M4Gy)
Sorry in advance if I sound harsh but for a start you might like to use code tags and tidy up your blank lines and lack of indentation which makes you look as though you take no pride in your work. Your presentation is like a mad-womans @#$t

Once you overcome that hurdle you might like to consider 'fill' in all it's threefold lack of symmetry. :)
Topic archived. No new replies allowed.