954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Towers of Hanoi

ok im trying to make the towers of hanoi program but i get the following compile error: [Linker error] undefined referrence to 'WinMain@16'

Heres the code, thanks for any help

#include <iostream>
#include <cstdlib>

using namespace std;

void towers (int numDisks, char source, char dest, char auxiliary)
{
    static int step = 0;

    cout << "Towers (" << numDisks << ", " << source << ", " << dest << ", " << auxiliary << ")\n";
        if (numDisks == 1)
                cout << "\t\t\t\t\tStep " << ++step << ": Move from " << source << " to " << dest << endl;
        else 
           {
            towers (numDisks - 1, source, auxiliary, dest);
             cout << "\t\t\t\t\tStep " << ++step << ": Move from " << source << " to " << dest << endl;
             towers (numDisks - 1, auxiliary, dest, source);
            } 
        return;
}
WrEcK
Newbie Poster
8 posts since Nov 2004
Reputation Points: 10
Solved Threads: 0
 

>undefined referrence to 'WinMain@16'
You're compiling as a Win32 application, not a console application. But either way you would get an error as you haven't defined main at all, whether it be the C++ main or the Win32 API WinMain.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You