Thread: unresolved externals??

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    8

    unresolved externals??

    I re-edited my program but now whenever I try to compile it, it says that I have 2 unresolved externals. The only place where I declared external variables was before the calcPay() function, but I still got the same error message when I commented that line out. What's wrong with my program?


    Here's what the error messages say:

    error LNK2020: unresolved token (0A000014) _streams

    error LNK2001: unresolved external symbol

    fatal error LNK1120: 2 unresolved externals
    Code:
    #include <stdio.h>
    #include <string.h> 
    
    // gets name and hourlyrate and hours worked from user
    
    
    
    void userInput(char nameArray[][30], double hoursWorkedArray[], double hourlyRateArray[])
    	{
    		double hours[5], rate[5];
    		int i;
    		for (i=0; i<5; i++)
    		{
    
    		printf("Enter name.\n");
    		fflush(stdin);
    		scanf("&#37;s", nameArray[i]);
    		printf("How many hours did they work this week?\n");
    		scanf("%lf", &hours[i]);
    		printf("What is their hourly rate?\n");
    		scanf("%lf", &rate[i]);
    
    		*hoursWorkedArray = hours[0];
    		*hourlyRateArray = rate[0];
    
    		}
    	
    		
    	}
    
    
    
    // calculates base,gross,overtime, and net pay
    double grossPay[5], basePay[5], overTime[5], netPay[5];
    
    double calcPay (double hoursWorkedArray[], double hourlyRateArray[])
    {
    
    	double base[5], over[5], gross[5], net[5];
    		int i;
    		for (i=0; i<5; i++)
    		{
    			if (hoursWorkedArray[i] > 40)
    			{
    				base[i] = hourlyRateArray[i] * hoursWorkedArray[i];
    				over[i] = (hoursWorkedArray[i] - 40) * 1.5 * hourlyRateArray[i];
    				gross[i] = (hourlyRateArray[i]*40) + over[i];
    				net[i] = (hourlyRateArray[i]*40) + over[i] - ((hourlyRateArray[i]*40) + over[i])*.2;
    				grossPay[i] = gross[i];
    				basePay[i] = base[i];
    				overTime[i] = over[i];
    				netPay[i] = net[i];
    
    				
    			
    			}
    			else
    			{
    				base[i] = hourlyRateArray[i] * hoursWorkedArray[i];
    				//taxesOwed[i] = (hourlyRateArray[i]*40) * .2;
    				gross[i] = (hourlyRateArray[i]*40) * .8;
    				over[i] = 0;
    				net[i] = (hourlyRateArray[i]*40) + over[i] - ((hourlyRateArray[i]*40) + over[i])*.2;
    				grossPay[i] = gross[i];
    				basePay[i] = base[i];
    				overTime[i] = over[i];
    				netPay[i] = net[i];
    				
    
    			}
    		}
    
    
    	return *grossPay;
    		
    }
    
    // calculates taxes owed
    double calcTax (double *grossPay)
    {
    	double taxPaid[5];
    	int i;
    		for (i=0; i<5; i++)
    		{
    		
    
    			taxPaid[i] = *(grossPay + i) * .2;
    			return taxPaid[i];
    			
    			
    		}
    
    	
    
    }
    
    //calculates the total amount paid to five emplorees
    double totalPaid (double hoursWorkedArray[], double hourlyRateArray[])
    {
    
    	double a,b,c,d,e;
    	a = calcPay(hoursWorkedArray, hourlyRateArray); 
    	b = calcPay(hoursWorkedArray+1, hourlyRateArray+1); 
    	c = calcPay(hoursWorkedArray+2, hourlyRateArray+2); 
    	d = calcPay(hoursWorkedArray+3, hourlyRateArray+3); 
    	e = calcPay(hoursWorkedArray+4, hourlyRateArray+4); 
    
    
    	return a+b+c+d+e;
    }
    
    void printPay(char nameArray[][30], double hoursWorkedArray[], double hourlyRateArray[])
    {
    	calcPay(hoursWorkedArray, hourlyRateArray);
    	double tax = calcTax(grossPay);
    	int i;
    	for (i=0; i<5; i++)
    	{
    		printf("Pay to %s: \n", nameArray[i]);
    		printf("Hours worked: %.2f\n", hoursWorkedArray+i);
    		printf("Hourly rate: $%.2f\n", hourlyRateArray+i);
    		printf(" Base pay: $%.2f\n Gross pay: $%.2f\n Gross pay: $%.2f\n Net pay: $%.2f\n Taxes paid: $%.2f\n", basePay[i], grossPay[i], netPay[i], tax);
    
    
    	}
    
    
    
    }
    
    
    int main(void)
    {
    
    	double hourlyRate[5], hoursWorked[5];
    	char name[5][30];
    
    	userInput(name, hourlyRate, hoursWorked);
    	printPay(name, hourlyRate, hoursWorked);
    
    	return 0;
    }
    Last edited by pokiepo; 07-01-2008 at 07:58 PM.

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    My Carnak hat is at the cleaners. Can you post the error messages?
    Mainframe assembler programmer by trade. C coder when I can.

  3. #3
    Registered User
    Join Date
    Jun 2008
    Posts
    8
    Haha sorry.

    Here's what the error messages say:

    error LNK2020: unresolved token (0A000014) _streams

    error LNK2001: unresolved external symbol

    fatal error LNK1120: 2 unresolved externals

  4. #4
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    Makes no sense to me. You don't have any references to anything remotely close to an identifier named "streams".
    Mainframe assembler programmer by trade. C coder when I can.

  5. #5
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    compiles fine here (gcc 4.1.2, Linux)

  6. #6
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    I believe stdin might be a reference to _streams, but that would mean he broke linking with the C standard library, which is kind of..... bad.

  7. #7
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Invisible text that doesn't apply to you: [How are you compiling the program? Something like this should work:
    Code:
    gcc program.c -o program
    Have you upgraded GCC or your standard libraries, by any chance? If you're not recompiling your source code, just linking it, you might get linker errors that way. I suppose.
    ]

    I was assuming that you were using GCC, but I see that the error messages are from MSVC, so never mind that. Have you tried re-creating a project? Are you using a Console project or whatever you need to do with MSVC? . . . .

    The only thing I can find with Google is this, but I seriously doubt it will be useful. http://blog.instedit.com/2008/06/wha...you-blind.html
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  4. Unresolved Externals
    By nickname_changed in forum C++ Programming
    Replies: 10
    Last Post: 08-31-2003, 06:13 PM
  5. debug to release modes
    By DavidP in forum Game Programming
    Replies: 5
    Last Post: 03-20-2003, 03:01 PM