5 Replies - 3262 Views - Last Post: 23 January 2011 - 07:23 PM Rate Topic: -----

#1 DanFurgason   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 23-January 11

Receiving fatal error LNK1120: 1 unresolved externals even with main()

Posted 23 January 2011 - 05:59 PM

//This program calculates a theatres gross and net box office profits for a night.
//This program will ask for the name of the movie and the number of child tickets
//sold as well as the number of adult tickets sold.
//The price of an adult ticket is $6.00; a childs is $3.00.

#include <iostream>
#include <iomanip>
#include <conio.h>
using namespace std;


void main()
{
	const double CHILD_TICKET = 3.00
	const double ADULT_TICKET = 6.00
	const double THEATRE_PERCENTAGE = 0.20
	char movie name[41]

	double childticketsold, adultticketsold, grossprofit, amountpaid, netprofit;

	cout << "What is the name of the movie?" << endl;
	cin >> movie name;
	cout << "How many child tickets were sold?" << endl;
	cin >> childticketsold;
	cout << "How many adult tickets were sold?" << endl;
	cin >> adultticketsold;

	cout << "The name of the movie is:" << movie name << endl;
	cout << "The number of adult tickets sold is:" << adultticketsold << endl;
	cout << "The number of child tickets sold is:" << childticketsold << endl;

	grossprofit = (adultticketsold * ADULT_TICKET) + (childticketsold * CHILD_TICKET);
	cout << "The gross box office profit is:" << grossprofit << endl;
	amountpaid = grossprofit - (grossprofit * THEATRE_PERCENTAGE);
	cout << "The amount paid to the distributor is:" << amountpaid << endl;
	netprofit = grossprofit - amountpaid;
	cout << "The net box office profit is:" << netprofit << endl;
	
	getch();
}


Is This A Good Question/Topic? 0
  • +

Replies To: Receiving fatal error LNK1120: 1 unresolved externals even with main()

#2 Slumdog   User is offline

  • D.I.C Head

Reputation: 34
  • View blog
  • Posts: 116
  • Joined: 26-November 10

Re: Receiving fatal error LNK1120: 1 unresolved externals even with main()

Posted 23 January 2011 - 06:23 PM

C++ standards states that main must be a int-type function and must return 0.
Was This Post Helpful? 0
  • +
  • -

#3 Martyr2   User is offline

  • Programming Theoretician
  • member icon

Reputation: 5257
  • View blog
  • Posts: 14,073
  • Joined: 18-April 07

Re: Receiving fatal error LNK1120: 1 unresolved externals even with main()

Posted 23 January 2011 - 06:25 PM

First of all, you are missing semicolons after each of your variable definitions...

// See the semicolons?
const double CHILD_TICKET = 3.00;
const double ADULT_TICKET = 6.00;
const double THEATRE_PERCENTAGE = 0.20;
char movie_name[41];



Next, you can't have a space in variable names. So you can't have a variable called "movie name". So replace the space with an underscore or delete the space. As you can see, I added an underscore to make it "movie_name".

Fix these two things and make sure that it is "int main()" and add a return 0; statement at the end. I figure I would mention it before you suffer the wrath of the C/C++ nazis who will go after you for doing void main() instead of int main(). void main() is not proper C/C++

:)
Was This Post Helpful? 1
  • +
  • -

#4 DanFurgason   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 23-January 11

Re: Receiving fatal error LNK1120: 1 unresolved externals even with main()

Posted 23 January 2011 - 06:46 PM

Thank you for your advice; I've made the changes you suggested:
int main()
{
	const double CHILD_TICKET = 3.00;
	const double ADULT_TICKET = 6.00;
	const double THEATRE_PERCENTAGE = 0.20;
	char movie_name[41];
return 0;
}


But I am still receiving this error message:
1>------ Build started: Project: Lab 3, Configuration: Debug Win32 ------
1>LINK : error LNK2001: unresolved external symbol _mainCRTStartup
1>C:\Users\Matt\Documents\Visual Studio 2010\Projects\Lab 3\Debug\Lab 3.exe : fatal error LNK1120: 1 unresolved externals
Was This Post Helpful? 0
  • +
  • -

#5 Slumdog   User is offline

  • D.I.C Head

Reputation: 34
  • View blog
  • Posts: 116
  • Joined: 26-November 10

Re: Receiving fatal error LNK1120: 1 unresolved externals even with main()

Posted 23 January 2011 - 07:03 PM

I think you created a Win32 application not a Console Application.
Was This Post Helpful? 1
  • +
  • -

#6 DanFurgason   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 23-January 11

Re: Receiving fatal error LNK1120: 1 unresolved externals even with main()

Posted 23 January 2011 - 07:23 PM

Yes that was the error; thank you both for your help :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1