Hey all,
I've spent the last couple hours looking at other posts with the same error and have still yet to figure out what is wrong. I'm just learning C++, I have a bit of experience with Python but, still just getting my feet wet.
Here is the code.
#include "stdafx.h"
#include <iostream>
using namespace std;
int winmain()
{
cout << "Palindrome Test" << endl;
char *charlist;
//Pointer for the array, so the user can specify the size.
int numchars;
//Variable for the number of characters in the array
numchars = 5;
//Initializing numchars
int counter,counter2;
//Two int counters, one to count up and one to count backwards
charlist = new char [numchars-1];
//Create array charlist
bool paltest;
paltest = true;
//Boolian variable, used for whether the string is a palindrome or not
int Inputstring ( );
{
cout << "How many characters are in your string?" << endl;
cin >> numchars;
//Sets user defined number of characters
cout << "Enter in the characters you would like to test:" << endl;
for ( counter = 0; counter < numchars; counter++)
{
cin>>charlist[counter];
cout << charlist[counter];
}
//Input the user's characters into string and print string to verify it is correct
cout << endl;
return 0;
}
bool PalindromeTest ( );
{
counter2 = numchars-1;
//Set counter 2 to user specified number of characters
for (counter = 0; counter < numchars/2; counter++)
{
if ( charlist[counter] == charlist[counter2] )
{
cout << "Match: " << charlist[counter] << "," << charlist [counter2] << endl;
counter2 = counter2--;
continue;
//If the characters in the nth position from start and from the end are the same, it is still a palindrome, print the characters and continue.
}
else
{
paltest = false ;
cout << "No Match: " << charlist[counter] << "," << charlist[counter2] << endl;
break;
//If the characters in the nth position from start and from the end aren't the same, stop checking for palindrome, its false.
}
system ("pause");
return paltest;
}
}
bool m = PalindromeTest ();
cout << m << endl;
//Call function Palindromeest
char PrintMessage ( m );
{
switch ( m )
{
case (true):
cout << " is a palindrome!" << endl;
case (false):
cout << " is not a palindrome!" << endl;
}
return 0;
}
system ("pause");
return 0;
}
and the error messages
1>------ Build started: Project: palindrome, Configuration: Debug Win32 ------
1> palindrome.cpp
1>palindrome.obj : error LNK2019: unresolved external symbol "bool __cdecl PalindromeTest(void)" (?PalindromeTest@@YA_NXZ) referenced in function "int __cdecl winmain(void)" (?winmain@@YAHXZ)
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>c:\documents\palindrome: fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I've tried switching main to winmain, and also changing it from a console application to a win32 application. Neither of these helped, anything would be great, even a point to another forum that discusses the problem in more depth.
Mike