Thread: Debug Error Really Quick Question

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    133

    Debug Error Really Quick Question

    So this program I'm writing is due to 2 hours and I just came across this error. I can't seem to find what I've messed up; I'm sure it's nothing serious could someone point it out? Here is the debug error with the code to follow.

    1>------ Build started: Project: P4, Configuration: Debug Win32 ------
    1>Compiling...
    1>P4.cpp
    1>Linking...
    1>LINK : warning LNK4076: invalid incremental status file '.\Debug/P4.ilk'; linking nonincrementally
    1>P4.obj : error LNK2019: unresolved external symbol "int __cdecl second_Mov_Greater(float * const,float * const)" (?second_Mov_Greater@@YAHQAM0@Z) referenced in function _main
    1>P4.obj : error LNK2019: unresolved external symbol "int __cdecl first_Mov_Greater(float * const,float * const)" (?first_Mov_Greater@@YAHQAM0@Z) referenced in function _main
    1>.\Debug/P4.exe : fatal error LNK1120: 2 unresolved externals
    1>Build log was saved at "file://e:\Project 4\Debug\BuildLog.htm"
    1>P4 - 3 error(s), 1 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


    Code:
    //Doug Miller
    
    //Project #4 - Working with stock information and organizing them.
    
    #include <stdio.h>
    
    #include <conio.h>
    
    #include "util.h"
    
    
    
    
    #define MAX_STOCKS 20
    #define MOV_MAX 16
    
    float stock1[MAX_STOCKS] = 
    {34.25,40.50,36.50,40.00,
    30.25,30.25,35.50,36.00,
    34.25,37.00,34.00,35.00,
    36.25,34.25,40.50,41.50,
    41.50,40.00,36.50,34.50};
    
    float mov_Stock1[MOV_MAX] = {0.0};
    
    
    float  stock2[MAX_STOCKS] = 
    {40.25,38.50,34.50,33.50,
    30.50,29.75,37.50,38.00,
    34.75,38.00,34.25,37.00,
    34.25,37.50,34.50,38.50,
    37.50,37.25,38.25,37.50};
    
    float mov_Stock2[MOV_MAX] = {0.0};
    
    
    
    //Report 1 Functions
    int first_Greater (float stock1[], float stock2[]);
    int second_Greater (float stock1[], float stock2[]);
    int same_Price (float stock1[], float stock2[]);
    void print_Report1(int first_Greater, int second_Greater, int same_Price);
    //END OF REPORT 1 FUNCTIONS
    
    //Report 2 Functions
    double average_First (float stock1[]);
    double average_Second (float stock2[]);
    int exceeded_Average_First (float stock1[], double average_First);
    int exceeded_Average_Second (float stock2[], double average_Second);
    void print_Report2 (double average_First, double average_Second, int exceeded_Average_First, int exceeded_Average_Second);
    
    
    //END OF REPORT 2 FUNCTIONS
    
    //Report 3 Functions
    void calc_Mov_Average (float stock[], float movAvg[]);
    void print_Report3 (float mov_Stock1[], float mov_Stock2[]);
    
    
    //END OF REPORT 3 FUNCTIONS
    
    
    //Report 4 Functions
    
    int first_Mov_Greater (float mov_Stock1[], float mov_Stock2[]);
    int second_Mov_Greater (float mov_Stock1[], float mov_Stock2[]);
    int mov_Same (float mov_Stock1[], float mov_Stock2[]);
    void print_Report4 (int first_Mov_Greater, int second_Mov_Greater, int mov_Same);
    
    //END OF REPORT 4 FUNCTIONS
    
    
    
     
    
    int main()
    
    {
    	
    	
    	
    	
    							//BEGINNING OF REPORT 1 VARIABLES
    
    	int first_Greater_C = 0;
    	int second_Greater_C = 0;
    	int same_C = 0;
    							//END OF REPORT 1 VARAIABLES
    
    						
    							//BEGINNING OF REPORT 2 VARIABLES
    
    	double average_First_C = 0.0;
    	double average_Second_C = 0.0;
    	int exceeded_Average_CF = 0;
    	int exceeded_Average_CS = 0;
    
    							//END OF REPORT 2 VARAIABLES
    
    							//BEGINNIGN OF REPORT 4 VARIABLES
    
    	int mov_First_Greater_C = 0;
    	int mov_Second_Greater_C = 0;
    	int mov_Same_C = 0;
    
    							//END OF REPORT 4 VARAIBALES
    	
    	
    							
    							//BEGINNING OF REPORT 1 CALLS
    
    	//Print Title
    	PrintTitle();
    
    	//Print Date
    	PrintDate(); 
    
    	//Find First Stock Being Greater 
    	first_Greater_C = first_Greater(stock1, stock2);
    
    	//Find Second Stock Being Greater
    	second_Greater_C = second_Greater(stock1, stock2);
    
    	//Finding The Stocks To Be The Same
    	same_C = same_Price(stock1, stock2);
    
    	//Printing Report 1
    	print_Report1(first_Greater_C, second_Greater_C, same_C);
    
    	//Pause Screen
    	PauseScreen();
    
    							//END OF REPORT 1 CALLS
    
    
    							//BEGINNING OF REPORT 2 CALLS
    	
    	//Print Title
    	PrintTitle();
    
    	//Print Date
    	PrintDate();
    	
    	//Find Average FIRST DAY
    	average_First_C = average_First(stock1); 
    
    	//Find Average SECOND DAY
    	average_Second_C = average_Second(stock2); 
    
    	//Exceeded Average FRIST DAY
    	exceeded_Average_CF = exceeded_Average_First(stock1, average_First_C);
    
    	//Exceeded Average SECOND DAY
    	exceeded_Average_CS = exceeded_Average_Second(stock2, average_Second_C);
    
    	//Printing Report 2
    	print_Report2(average_First_C, average_Second_C, exceeded_Average_CF, exceeded_Average_CS);
    
    	//Pause Screen
    	PauseScreen();
    
    
    							//END OF REPORT 2 CALLS
    
    
    							//BEGINNING OF REPORT 3 CALLS
    	
    	//Print Title
    	PrintTitle();
    
    	//Print Date
    	PrintDate();
    	
    	//Find floating average first stock
    	calc_Mov_Average(stock1, mov_Stock1); 
    
    	//Find floating average second stock
    	calc_Mov_Average(stock2, mov_Stock2);
    
    	//Printing Report 3
    	print_Report3(mov_Stock1, mov_Stock2);
    
    	//Pause Screen
    	PauseScreen();
    
    
    							//END OF REPORT 3 CALLS
    
    
    
    							//BEGINNING OF REPORT 4 CALLS
    
    	//Print Title
    	PrintTitle();
    
    	//Print Date
    	PrintDate(); 
    
    	//Find First Stock MOVING AVERAGE Being Greater 
    	mov_First_Greater_C = first_Mov_Greater(mov_Stock1, mov_Stock2);
    
    	//Find Second Stock MOVING AVERAGE Being Greater
    	mov_Second_Greater_C = second_Mov_Greater(mov_Stock1, mov_Stock2);
    
    	//Finding MOVING AVERAGE To Be The Same
    	mov_Same_C = mov_Same(mov_Stock1, mov_Stock2);
    
    	//Printing Report 4
    	print_Report4(mov_First_Greater_C, mov_Second_Greater_C, mov_Same_C);
    
    	//Pause Screen
    	PauseScreen();
    
    							//END OF REPORT 4 CALLS
    
    
    
    
    _getch();
    
    return 0;
    
    }//END OF MAIN
    
    int first_Greater (float stock1[], float stock2[])
    {
    
    	int i = 0;
    	int f_Greater_Count = 0;
    
    	for (i = 0; i < MAX_STOCKS; i++)
    	{
    		if (stock1[i] > stock2[i])
    			{	
    				f_Greater_Count = f_Greater_Count + 1;
    			}
    	}
    
    
    	return f_Greater_Count;
    
    
    }//END OF COUNTING THE FIRST STOCK BEING GREATER
    
    int second_Greater (float stock1[], float stock2[])
    {
    
    	int i = 0;
    	int s_Greater_Count = 0;
    
    	for (i = 0; i < MAX_STOCKS; i++)
    	{
    		if (stock1[i] < stock2[i])
    			{	
    				s_Greater_Count = s_Greater_Count + 1;
    			}
    	}
    
    
    	return s_Greater_Count;
    
    
    }//END OF COUNTING THE SECOND STOCK BEING GREATER
    
    int same_Price (float stock1[], float stock2[])
    
    {
    
    	int i = 0;
    	int same_Count = 0;
    
    	for (i = 0; i < MAX_STOCKS; i++)
    	{
    		if (stock1[i] == stock2[i])
    			{	
    				same_Count = same_Count + 1;
    			}
    	}
    
    
    	return same_Count;
    
    
    }//END OF FIND THE STOCKS BEING THE SAME
    
    
    void print_Report1(int first_Greater, int second_Greater, int same_Price)
    {
    
    	printf("REPORT ONE\n\n");
    	printf("The amount of days stock one is greater is: %d\n\n", first_Greater);
    	printf("The amount of days the stock two is greater is: %d\n\n", second_Greater);
    	printf("The amount of days the stocks are the same is: %d\n\n", same_Price);
    
    }//END OF PRINTING REPORT 1
    
    
    double average_First (float stock1[])
    {
    
    	double average = 0;
    	double sum = 0;
    
    		for (int i = 0; i < MAX_STOCKS; i++)
    		{	
    			sum = (stock1[i] + sum); 
    		}
    
    		average = (sum/(double)MAX_STOCKS);
    
    	return average;
    
    
    }//END OF FINDING AVERAGE
    
    double average_Second (float stock2[])
    {
    
    	double average = 0;
    	double sum = 0;
    
    		for (int i = 0; i < MAX_STOCKS; i++)
    		{	
    			sum = (stock2[i] + sum); 
    		}
    
    		average = (sum/(double)MAX_STOCKS);
    
    	return average;
    
    
    }//END OF FINDING AVERAGE
    
    int exceeded_Average_First (float stock1[], double average_First)
    
    {
    	
    	int i = 0;
    	int first_Greater_C = 0;
    	
    	for (i = 0; i < MAX_STOCKS; i++)
    	{
    		if (stock1[i] > average_First)
    			{ 
    				first_Greater_C = (first_Greater_C + 1);
    				//printf("Stock[%d]: %f Count: %d\n\n", i, stock1[i], first_Greater_C); 
    			}
    	}
    
    
    	return first_Greater_C;
    
    
    }// END OF EXCEEDED FIRST AVERAGE
    
    
    int exceeded_Average_Second (float stock2[], double average_Second)
    
    {
    	
    	int i = 0;
    	int second_Greater_C = 0;
    	
    	for (i = 0; i < MAX_STOCKS; i++)
    	{
    		if (stock2[i] > average_Second)
    			{ 
    				second_Greater_C = (second_Greater_C + 1);
    			}
    	}
    
    	return second_Greater_C;
    
    
    }// END OF EXCEEDED FIRST AVERAGE
    
    void print_Report2 (double average_First, double average_Second, int exceeded_Average_First, int exceeded_Average_Second)
    
    {
    
    	printf("REPORT 2\n\n");
    	printf("The average of the first stock is %.2lf\n\n", average_First);
    	printf("The average of the second stock is %.2lf\n\n", average_Second);
    	printf("The first stock exceeded it's average %d times\n\n", exceeded_Average_First);
    	printf("The second stock exceeded it's average %d times\n\n", exceeded_Average_Second);
    
    }// END OF PRINTING REPORT 2
    
    void calc_Mov_Average (float stock[], float movAvg[])
    {
    
    	int i = 0;
    	int mov_Index = 0;
    	int prime_Count = 0;
    	float running_Sum = 0;
    
    	for (i = 0; i < MAX_STOCKS; i++)
    	{
    		//Prime running sum with first 5 elements
    		if (prime_Count < 5)
    		{
    			running_Sum = (stock[i] + running_Sum);
    
    			//On fifth element calc first moving average
    			if (prime_Count = 4)
    			{
    					movAvg[mov_Index] = (running_Sum/5);
    					mov_Index++;
    			}
    
    			prime_Count = (prime_Count + 1);
    		}
    		else
    		{
    			//Calc running sum on remaining elements
    			//	By adding the next elements in the sum and subtracting the element before the sum
    			running_Sum = ((running_Sum + stock[i]) - stock[i-5]); 
    			movAvg[mov_Index] = (running_Sum/5);
    			mov_Index++;
     		}
    	
    	}//END OF FOR
    
    }//END OF CALC MOVING AVERAGE
    
    
    void print_Report3 (float mov_Stock1[], float mov_Stock2[])
    
    {
    
    	int i = 0;
    	int start = 1;
    	int stop = 5;
    
    	for (i = 0; i < MOV_MAX; i++)
    	{
    		
    		printf("REPORT 3\n\n");
    		printf("Day %d to %d for stock 1: %f\n\n", start, stop, mov_Stock1[i]);
    		printf("Day %d to %d for stock 2: %f\n\n", start, stop, mov_Stock2[i]);
    		
    		start++;
    		stop++;
    
    	}//END OF FOR
    
    		
    
    }//END OF PRINTING REPORT 3
    
    
    int mov_First_Greater (float mov_Stock1[], float mov_Stock2[])
    {
    
    	int i = 0;
    	int movf_Greater_Count = 0;
    
    	for (i = 0; i < MOV_MAX; i++)
    	{
    		if (mov_Stock1[i] > mov_Stock2[i])
    			{	
    				movf_Greater_Count = movf_Greater_Count + 1;
    			}
    	}
    
    
    	return movf_Greater_Count;
    
    
    }//END OF COUNTING THE FIRST STOCK BEING GREATER
    
    int mov_Second_Greater (float mov_Stock1[], float mov_Stock2[])
    {
    
    	int i = 0;
    	int movs_Greater_Count = 0;
    
    	for (i = 0; i < MOV_MAX; i++)
    	{
    		if (mov_Stock1[i] < mov_Stock2[i])
    			{	
    				movs_Greater_Count = movs_Greater_Count + 1;
    			}
    	}
    
    
    	return movs_Greater_Count;
    
    
    }//END OF COUNTING THE SECOND STOCK BEING GREATER
    
    int mov_Same (float mov_Stock1[], float mov_Stock2[])
    
    {
    
    	int i = 0;
    	int mov_Same_Count = 0;
    
    	for (i = 0; i < MOV_MAX; i++)
    	{
    		if (mov_Stock1[i] == mov_Stock2[i])
    			{	
    				mov_Same_Count = mov_Same_Count + 1;
    			}
    	}
    
    
    	return mov_Same_Count;
    
    
    }//END OF FIND THE STOCKS BEING THE SAME
    
    void print_Report4(int first_Mov_Greater, int second_Mov_Greater, int mov_Same)
    {
    
    	printf("REPORT FOUR\n\n");
    	printf("The amount of days the moving average was greater for the first stock is: %d\n\n", first_Mov_Greater);
    	printf("The amount of days the moving average was greater for the second stock is: %d\n\n", second_Mov_Greater);
    	printf("The amount of days the moving average is the same for both stocks is: %d\n\n", mov_Same);
    
    }//END OF PRINTING REPORT 4

  2. #2
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    The errors tell only that this functions
    Code:
    int first_Mov_Greater (float mov_Stock1[], float mov_Stock2[]);
    int second_Mov_Greater (float mov_Stock1[], float mov_Stock2[]);
    are not implemented anywhere.
    Kurt

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Very quick math question
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 10-26-2005, 11:05 PM
  2. very quick question.
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 07-24-2002, 03:48 AM
  3. quick question
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 07-22-2002, 04:44 AM
  4. Quick Question Regarding Pointers
    By charash in forum C++ Programming
    Replies: 4
    Last Post: 05-04-2002, 11:04 AM
  5. Quick question: exit();
    By Cheeze-It in forum C Programming
    Replies: 6
    Last Post: 08-15-2001, 05:46 PM