whats wrong with this?

This is a discussion on whats wrong with this? within the C++ Programming forums, part of the General Programming Boards category; Trying another small program, learning still and it wont work. Code: typedef unsigned short USHORT; #include <iostream> using namespace std; ...

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    132

    whats wrong with this?

    Trying another small program, learning still and it wont work.

    Code:
    typedef unsigned short USHORT;
    #include <iostream>
    using namespace std;
    
    USHORT FindArea(USHORT Length, USHORT Width); //Function prototype
    
    int main()
    {
    	USHORT LengthOfYard;
    	USHORT WidthOfYard;
    	USHORT AreaOfYard;
    
    	cout << "\nHow wide is the yard? ";
    	cin >> WidthOfYard;
    	cout << "\nHow long is the yard? ";
    	cin >> LengthOfYard;
    
    	AreaOfYard= FindArea(LengthOfYard,WidthOfYard);
    
    	cout << "\nYour Yard is ";
    	cout << AreaOfYard;
    	cout << " Square feet\n\n";
    	system("PAUSE");
    	return 0;
    }
    and the error is

    Code:
    ------ Build started: Project: function prototypes, Configuration: Debug Win32 ------
    Compiling...
    function prototypes.cpp
    Linking...
    function prototypes.obj : error LNK2019: unresolved external symbol "unsigned short __cdecl FindArea(unsigned short,unsigned short)" (?FindArea@@YAGGG@Z) referenced in function _main
    C:\Documents and Settings\Reece.LAPTOP\My Documents\Visual Studio 2005\Projects\function prototypes\Debug\function prototypes.exe : fatal error LNK1120: 1 unresolved externals
    Build log was saved at "file://c:\Documents and Settings\Reece.LAPTOP\My Documents\Visual Studio 2005\Projects\function prototypes\function prototypes\Debug\BuildLog.htm"
    function prototypes - 2 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    could someone please help me. i cannot find anything wrong with it. :-/

  2. #2
    Tropical Coder Darryl's Avatar
    Join Date
    Mar 2005
    Location
    Cayman Islands
    Posts
    503
    like the comment says, USHORT FindArea(USHORT Length, USHORT Width); //Function prototype is a function prototype. You need to define the function somewhere.

    Code:
    USHORT FindArea(USHORT Length, USHORT Width)
    {
         return Length*Width;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 07-15-2004, 04:30 PM
  2. Debugging-Looking in the wrong places
    By JaWiB in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 11-03-2003, 10:50 PM
  3. Confused: What is wrong with void??
    By Machewy in forum C++ Programming
    Replies: 19
    Last Post: 04-15-2003, 01:40 PM
  4. God
    By datainjector in forum A Brief History of Cprogramming.com
    Replies: 746
    Last Post: 12-22-2002, 12:01 PM
  5. Whats wrong?
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 07-14-2002, 02:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21