Error 2 error LNK1120: 1 unresolved externals

Nov 18, 2012 at 8:38pm
hi friends
i have this error (Error 2 error LNK1120: 1 unresolved externals C:\Users\Aqeel\Documents\Visual Studio 2010\Projects\Aqeel string 3\Debug\Aqeel string 3.exe
)
can any one tell me how to fix it ?
my code is
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <string>
#include <string.h>
using namespace std;

void deleteChar(string,char);

int mian()
{
	string A="this is my programme";
	char a;
	cout<<"\nenter the character that you want to count: ";
	cin>>a;
	deleteChar(A,a);
	getch();
	return 0;
}
void deleteChar(string A,char a)
{
	int b=A.find(a);
	for(int i = 0; i < A.length(); i++)
    {
		A.erase(b);
	}  
	cout<<A;
	
}
Nov 18, 2012 at 8:52pm
That looks like only part of the error message. The "unresolved external" is function main().

Your code has this instead: int mian()
Nov 18, 2012 at 8:54pm
that is what i got on my output section...

1>------ Build started: Project: Aqeel string 3, Configuration: Debug Win32 ------
1>Build started 11/19/2012 1:53:43 AM.
1>InitializeBuildStatus:
1> Touching "Debug\Aqeel string 3.unsuccessfulbuild".
1>ClCompile:
1> All outputs are up-to-date.
1> All outputs are up-to-date.
1>ManifestResourceCompile:
1> All outputs are up-to-date.
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Users\Aqeel\Documents\Visual Studio 2010\Projects\Aqeel string 3\Debug\Aqeel string 3.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.25
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Nov 18, 2012 at 8:57pm
Indeed: unresolved external symbol _main
Anyway, the solution is as above, change your mian to main.
Nov 18, 2012 at 8:58pm
i didnt get what you want to say :(
Nov 18, 2012 at 9:04pm
I said it twice.

Once more.

change this:
int mian()
to this:
int main()



----------------------------------------------------------
My other comments referred to the fact that somewhere in the middle of the messages is the piece of useful information, which tells you what is wrong. When a program is compiled and linked, various names such as function names are stored internally in a slightly different format, hence you see "_main" rather than just "main" in the message. It's worth remembering that, because sooner or later you'll meet similar errors in the future, and if you know how to interpret the error messages, then you have a clue as to what might need to be changed in order to fix it.
Nov 18, 2012 at 9:08pm
oooo man :)
thanks i got it
Topic archived. No new replies allowed.