Linker error

Hi everyone

I'm not only new to C++, I'm new to VS 2013 Pro. I wrote this trivial program just to see if I could get it to compile and I'm getting the following errors:


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
30
31
32
33
34
35
36
#include <iostream>
using namespace std;



int Main()
{
	int i;
	int Num = 0;

	for (i = 1; i < 12; i++)
	{
		string tab = "\t";
		int Num = i;

		cout << Num;
		cout << "tab";

		if (Num = 3)
		{
			cout << endl;
		}
		if (Num = 6)
		{
			cout << endl;
		}
		if (Num = 12)
		{
			cout << endl;
		}
		return 0;

		cout << "Press enter to stop";
		cin.get();
	}
}


1
2
3
4
1>c:\users\paule\documents\visual studio 2013\projects\numbergrid\numbergrid\number.cpp(36):
 warning C4715: 'Main' : not all control paths return a value
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol 
_main referenced in function ___tmainCRTStartup


I've tried everything I can think of and made sure my braces line up. Also all my semicolons are in order I think.

I also researched the problem on the internet and what I camme up with doesn't really seem to make a difference (ie; project-properties-linker-subsystem-Console).

If anyone is familiar with VS 2013 and can help me with this I would appreciate it.

Thank you!
Two things:

First, logic wise, why do you have the 'return 0' statement on line 31? You will only iterate once, because you will meet the return statement in the for loop before it iterates. Moving it outside the loop will also fix your warning.

As for you error: its supposed to be int main() rather than int Main() - C++ is a case-sensitive language.
Last edited on
Thank you for your answer. I changed the int main() and everything worked fine.
Topic archived. No new replies allowed.