Weird Error..

Hey there, this is my code:

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include <iostream>
#include <iomanip>
using namespace std;



struct american 
{
	int ounce;
	int tablesp;
	int Teasp;
};


american a_american(int o, int tbl, int tsp);

american a_american(int o);

void print(const american& a_american);

american addition(american a1, american a2);

american multiplication(american a1, american a2);

void read(american* a);

american a_american(int Oz, int tbl, int Tsp)
{
	american temp;

	temp.ounce = Oz;
	temp.tablesp = tbl;
	temp.Teasp = Tsp;

	return temp;
}


american a_american(int Oz)
{
	american temp;
	temp.ounce = Oz / 6;  //3 teaspoons * 2 tablespoons in an ounce
	Oz %= 6;
	temp.tablesp = Oz / 3;  //3 teaspoons in a tablespoon
	temp.Teasp = Oz % 3;

	return temp;
}


void print(american a_american)
{
	cout << a_american.ounce << endl;
	cout << a_american.tablesp << endl;
	cout << a_american.Teasp << endl;

}


american addition(american a1, american a2)
{
	int P1 = a1.ounce * 6 + a1.tablesp * 3 + a1.Teasp;
	int P2 = a2.ounce * 6 + a2.tablesp * 3 + a2.Teasp;

	return a_american (P1 + P2);

}

american multiplication(american a1, american a2)
{
	int i1 = a1.ounce * 6 + a1.tablesp * 3 + a1.Teasp;
	int i2 = a2.ounce * 6 + a2.tablesp * 3 + a2.Teasp;

	return a_american (i1 * i2);
}


void read(american* US)
{
	cout << "Please enter the ounces:";
	cin >> US->ounce;
	cout << "Please enter the Tablespoons: ";
	cin >> US->tablesp;
	cout << "Please enter the teaspoons: ";
	cin >> US->Teasp;
}

/*int main ()
{

	american a;
	read (&a);
	print (a);

	american a = make_american(1, 2, 3);
	print(a);

	american a = add(
		return 0;

	return 0; 
}
*/


and here is the error I get. not sure what I'm doing wrong. Im using Visual Studio 2010 Professional:

1>------ Build started: Project: PT_Retake, Configuration: Debug Win32 ------
1>Build started 10/27/2012 10:02:40 PM.
1>PrepareForBuild:
1> Creating directory "c:\users\**** *******\documents\visual studio 2010\Projects\PT_Retake\Debug\".
1>InitializeBuildStatus:
1> Creating "Debug\PT_Retake.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>ClCompile:
1> american.cpp
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>c:\users\**** *******\documents\visual studio 2010\Projects\PT_Retake\Debug\PT_Retake.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.35
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Help? Thanks
Last edited on
It's not weird at all. You're creating an executable file with a main function. Uncomment your main function and it should work fine.
You need a 'main()' function to link - yours is commented out (see the /* before main and the */ after main - that's a comment)
herp derp! lol i can't believe i didn't catch that I'm getting errors on that, and I'm not sure what i can do. Any thoughts? (on the main)
Topic archived. No new replies allowed.