-
June 21st, 2012, 05:05 AM
#1
Baffling Link Error
I'm new to C++ programming and am writing a program to implement an insertion sort in an array. I decided to test out my printArray function before proceeding and keep getting a link error:
"MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup"
Here's the code(it's all in one .cpp file):
Code:
//main.cpp
#include <iostream>
#include <iomanip>
using namespace std;
//Function to print out contents of array
void printArray(const int a[], const int size);
int main(int argc, char* argv[])
{
const int arraySize = 10;
int data[arraySize] = {34, 56, 4, 10, 77, 51, 93, 30, 5, 52};
//Print out contents of usorted Array
cout << "Unsorted array:\n";
printArray(data, arraySize);
cout << endl;
return 0;
}
//Function to print out contents of array
void printArray(const int a[], const int size)
{
for(int i = 0; i < size; i++)
cout << setw(5) << a[i];
}
I have absolutely no idea what's causing this. I've checked my code over and over and just can't figure out the cause of the link error.
-
June 21st, 2012, 05:50 AM
#2
Re: Baffling Link Error
You have created a Win32 project instead of a Console project.
-
June 21st, 2012, 06:07 AM
#3
Re: Baffling Link Error
I was sure I had selected console. Well it compiles fine if I copy paste it to another new project so I guess I must have checked it as win32 project. Thanks for the help.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|