Thread: Problem Compiling

  1. #1
    #include <me!> Flakster's Avatar
    Join Date
    May 2005
    Location
    Canada
    Posts
    50

    Problem Compiling

    I'm having trouble compiling what I am working on in Visual C++ 2005 express edition. I also tried compiling the same code in Dev-C++ and still had problems. The code itself probably still has some bugs in it that need to be worked out, the problem here is that the build process is being stopped during linking.

    Code:
    Code:
    #include <iostream>
    #include <iomanip>
    
    int Main();
    int Constants(int &chapters, int &testWeight, int &assignmentWeight);
    int Chapters(int numChapters, int testWeight, int assignmentWeight);
    
    using namespace std;
    
    int Constants(int &numChapters, int &testWeight, int &assignmentWeight)
    {
    	bool correctRatio = false;
    
    	cout<<"Grade Tracker"<<endl<<endl;
    	cout<<"This program takes test and assignment marks from each chapter, and calculates"<<endl;
    	cout<<"each chapter average and overall average.  The weight for tests and assignments"<<endl;
    	cout<<"are necessary for this calculations."<<endl<<endl;
    	
    	while(correctRatio==true)
    	{
    	cout<<"Enter the weights for the tests and assignments."<<endl;
    	cout<<"NOTE:  The sum must be equal to one.  For example, enter 70% as 0.70"<<endl;
    	cout<<"		  for tests and then 30% as 0.30 for assignments."<<endl;
    	cout<<"\nTest weight: ";
    	cin>>testWeight;
    	cout<<"\nAssignment weight: ";
    	cin>>assignmentWeight;
    
    	if(testWeight + assignmentWeight == 1)
    	{
    		correctRatio = true;
    	}//end if
    	}//end while
    
    	while(numChapters <= 10)
    	{
    	cout<<"\n\nEnter the number of chapters."<<endl;
    	cout<<"NOTE:  There is a limit of 10 chapters possible."<<endl;
    	cout<<"Chapters: ";
    	cin>>numChapters;
    	}//end while
    }
    
    int Chapters(int numChapters, int testWeight, int assignmentWeight)
    {
    	bool chapterDone = false;
    	int chapterCounter;
    
    	for(chapterCounter = 0; chapterCounter == numChapters; chapterCounter++)
    	{
    	cout<<"Enter the test and assignment marks for each chapter."<<endl;
    	cout<<"Note:  There is a limit of 5 tests and 15 assignments per chapter."<<endl;
    	cout<<"Chapter "<<1+chapterCounter<<":";
    	}
    }
    
    int Main()
    {
    	int testWeight;
    	int assignmentWeight;
    	int numChapters;
    
    	Constants(numChapters, testWeight, assignmentWeight);
    
    	Chapters(numChapters, testWeight, assignmentWeight);
    }
    
    /*
    Enter the test and assignment marks for each chapter.
    Note:  There is a limit of 5 tests and 15 assignments per chapter.
    Chapter 1:
    Enter the or assignment mark <t or a> or go to next <n> chapter?
    Enter test mark:
    Enter assignment mark: 
    
    Your Grade Summary
    Chapter 1:
    	Assignment #1:	0 %
    	Test #1:	0 %
    	-------------------
    	Average:	0 %
    
    Chapter 2:
    	Assignment #1:	0 %
    	Test #1:	0 %
    	-------------------
    	Average:	0 %
    ===========================
    Final:			4 %
    
    Do you want to perform another calculation? <y or n>
    */
    Errors:
    Linking...
    MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
    D:\My Documents\Visual Studio 2005\Projects\Assignment 2-2\Debug\Assignment 2-2.exe : fatal error LNK1120: 1 unresolved externals
    Currently using Visual C++ 2005 Express Edition, 'cause it was free!

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Code:
    int Main()
    should be
    Code:
    int main()
    Case sensitive, you know.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    #include <me!> Flakster's Avatar
    Join Date
    May 2005
    Location
    Canada
    Posts
    50
    Wow.

    Hurrah for wasting two days of debugging over a stupid mistake.

    And, thank you.
    Currently using Visual C++ 2005 Express Edition, 'cause it was free!

  4. #4
    #include <me!> Flakster's Avatar
    Join Date
    May 2005
    Location
    Canada
    Posts
    50
    On another note, trying to put numbers with decimals into int variables is alot of fun.

    Maybe I should actually learn how to program before I start smashing my head on the keyboard and hope I end up with something that works.
    Currently using Visual C++ 2005 Express Edition, 'cause it was free!

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > Hurrah for wasting two days of debugging over a stupid mistake.
    Press compile every 5 minutes, not every 2 days.
    If you get a problem, then the mistake was in the last 5 minutes.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem Running Program After Compiling
    By kristentx in forum C++ Programming
    Replies: 13
    Last Post: 09-12-2007, 10:46 AM
  2. Problem compiling simple code examples
    By Wintersun in forum Windows Programming
    Replies: 8
    Last Post: 08-14-2007, 10:30 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  4. compiling problem
    By tinkerbell20 in forum C++ Programming
    Replies: 6
    Last Post: 06-21-2005, 12:12 PM
  5. simple compiling problem
    By waxydock in forum C++ Programming
    Replies: 2
    Last Post: 03-26-2005, 10:33 AM